如何使用 pdfbox 将相对超链接添加到一组 pdf 文件?
How do I add relative hyperlinks to a group of pdf files using pdfbox?
我目前正在实现解析一组 pdf 以检索每个 pdf 元的功能 data.And 然后通过在每个 pdf 中引用另一个 pdf 的地方添加超链接链接来互连这些 it.I 我可以在这些 pdf 上传到服务器后创建绝对 hyperlinks.But,然后它们可以从服务器下载到任何本地机器 path.I 希望这些超链接在下载到不同的 location.So 后工作, 如何创建相对于 pdf 组的超链接?
这是解决我的问题的代码:
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);
我目前正在实现解析一组 pdf 以检索每个 pdf 元的功能 data.And 然后通过在每个 pdf 中引用另一个 pdf 的地方添加超链接链接来互连这些 it.I 我可以在这些 pdf 上传到服务器后创建绝对 hyperlinks.But,然后它们可以从服务器下载到任何本地机器 path.I 希望这些超链接在下载到不同的 location.So 后工作, 如何创建相对于 pdf 组的超链接?
这是解决我的问题的代码:
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);