0

I have implemented functionality to add a relative link into a pdf using the pdfbox library.Below is the code that I am using for adding the link:

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

Here is the command entered in the pdf:

14 0 obj
<<
/Type /Filespec
/F (A-201-NORTH & SOUTHSITE ELEVATIONS.pdf)
>>
endobj

The links work in adobe, ios viewer. But does not work in PSPDF. Also, I have file whose link work in PSPDF. But the commands in that file differ slightly from the above.Here is the link command that works in the PSPDF:

113 0 obj
<<
/Type /Filespec
/F (A8.1 - INTERIOR ELEVATION.pdf)
/UF (A8.1 - INTERIOR ELEVATION.pdf)
/Desc()
>>

So, how do I create this command using pdfbox.

4

1 回答 1

1

要添加 /UF 条目,请使用setFileUnicode(String file).

要添加 /Desc 条目,请使用setFileDescription(String description).

我还包括 Rad 的答案,这是一个评论,可能会被删除:

如果您认为 PSPDFKit 存在问题,请在此处打开支持请求。我们很乐意提供帮助!

于 2017-10-27T09:20:10.640 回答