Utilizing PDF.js, my web application loads PDFs directly in the browser by fetching them from a REST API.
This single-page AngularJS web app allows users to navigate through various sections and access different PDF files. However, there seems to be an issue with accessing relative links within the Outline of the first PDF once it's opened.
Interestingly, when I directly access the PDF through the REST API URL like api.example.com/rest/my-pdf.pdf
using Firefox, everything works fine including the relative links within the Outline.
I suspect this problem might be due to my web app being on a different origin than the server hosting the PDFs via the REST API.
Each OutlineItem
contains an action dictionary with related relative links. The dictionary specifies an ActionType (S) as Launch
, along with a FileStream (F) value as shown below.
https://i.sstatic.net/5idLf.png
To view the PDFs, I'm utilizing the viewer.html file provided by PDF.js through an iframe setup:
<iframe src="/path/to/pdfjs/viewer.html?file=http://api.example.com/rest/my-pdf.pdf">
Any suggestions on how I can resolve the issue with relative links not working properly would be greatly appreciated.
P.S. For confidentiality, I've obscured only the actual filenames in red, while keeping the path intact for reference purposes.