【问题标题】:How do I add relative hyperlinks to a group of pdf files using pdfbox?如何使用 pdfbox 将相对超链接添加到一组 pdf 文件?
【发布时间】:2017-06-20 12:50:27
【问题描述】:

我目前正在实现解析一组 pdf 以检索每个 pdf 元数据的功能。然后通过在每个 pdf 中引用另一个 pdf 的地方添加超链接链接来相互链接。我能够创建绝对超链接。但是将这些 pdf 上传到服务器后,可以将它们从服务器下载到任何本地机器路径。我希望这些超链接在下载到不同位置后能够正常工作。那么,如何创建相对于 pdf 组的超链接?

【问题讨论】:

    标签: c# pdf hyperlink relative-path pdfbox


    【解决方案1】:

    这是解决我问题的代码:

    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);
    

    【讨论】:

      猜你喜欢
      • 2018-12-01
      • 2014-01-28
      • 1970-01-01
      • 2021-09-12
      • 1970-01-01
      • 2012-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多