且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用pdfbox向一组pdf文件添加相对超链接?

更新时间:2023-11-04 10:28:04

以下是解决我问题的代码:

Here is the code which solved my issue :

PDActionRemoteGoTo remoteGoto = new PDActionRemoteGoTo();
PDComplexFileSpecification fileDesc = new PDComplexFileSpecification();
fileDesc.setFile(System.IO.Path.GetFileName(filePath));
                            remoteGoto.setOpenInNewWindow(true);
                            remoteGoto.setFile(fileDesc);
                            txtLink.setAction(remoteGoto);
 txtLink.setRectangle(rect);
 page.getAnnotations().add(txtLink);