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.