Is it possible to rewrite Hyperlinks embedded in PDF using PDF.JS Express?

Which product are you using?
PDF.js Express Viewer

PDF.js Express Version

Detailed description of issue
Customers use our website to view PDFs via proxies.

The links in our PDFs break their proxy behaviour.


User goes to https://www-website-com.myproxy.tld/file and views PDF
PDF contains link to
User clicks link, and is no longer loading the website via their proxy (so is effectively signed out)

The proxies re-write URLs for anything embedded in HTML, but can’t do the same for PDFs

Expected behaviour

Not expected, just wondering whether there’s a mechanism to re-write the URLs of embedded hyperlinks. E.g. something would see non-proxied url and change the bit before /new to the hostname.

Does your issue happen with every document, or just one?

Link to document

Code snippet

I tried to use getAnnotationsManager().getAnnotationsList() but that didn’t result in objects that made sense to me.


docViewer.on("annotationsLoaded", () => {
  console.log("annotations loaded");
  const annots = annotManager.getAnnotationsList();
  annots.forEach((annotation) => {

I wonder if I can do this using pdf-lib but I don’t know how I’d pass the PDF into the WebViewer

Hi there,

Thank you for contacting pdf.js express forums,

For the hyperlinks in the PDF, you can see them as an annotation, for example in the demo site: PDF.js Viewer Demo | PDF.js Express

And these are types of link annotations we support:

Please note that the above guide is for express Pro, and the Viewer does not support link annotations: Internal links don't work in PDF.js Express viewer - #3 by system

Best regards,
Kevin Kim

Good to know, thank you Kevin!