Custom trigger to hyperlinks / link and goto that are already created in original PDF

PDF.js Express Version

Detailed description of issue
Hi, I am trying to display PDF documents that have external hyperlinks to files. First I need how to Active those links to work.
Second, I need somehow to catch the event when the user click the external hyperlink and try to redirect it to existing file in the server.

I try this link for PDFTRON but it don’t work.

Expected behaviour
{Provide a screenshot or description of the expected behaviour}
First, When the user click on the hyperlink, open a blank page with the link

Does your issue happen with every document, or just one?
{Answer here}

Link to document
{Provide a link to the document in question if possible}

Code snippet
{Provide a relevant code snippet}

Hey there! Thanks for trying out PDF.js Express.

You’re super close. For external links, you’ll actually want to override the URI Action instead of GoToR.

WebViewer(...).then(instance => {
  const uriTrigger = Actions.URI.prototype.onTriggered;
  Actions.URI.prototype.onTriggered = function(link) {
    //uriTrigger.apply(this, arguments); // uncomment this to use default functionality

With the URI you can do whatever you wish.

Let me know if theres anything else I can help with.


1 Like

Hi Logan, thank you for your answer.

I managed to do trigger my custom event with the PdfTron demo. How ever , I didn´t have success with the PDF.js Express demo.

In Pdf.js Express the annotations are not returning actions.

This is my code

path: ‘PDFJSExpress/lib’, // path to the PDF.js Express’lib’ folder on your server
licenseKey: ‘Insert commercial license key here after purchase’,
initialDoc: ‘WebViewer/samples/viewing/viewing/ejemplo3/test.pdf’,

    }, document.getElementById('viewer'))

        .then(instance => {
            const docViewer = instance.docViewer;
            const annotManager = instance.annotManager;
         //PDFTron return actions but PDF.JSExpress don't   
         docViewer.on('annotationsLoaded', () => {
                const annotations = annotManager.getAnnotationsList();
                annotations.forEach(annot => {
                    var a = annot.getActions();
                    if (a.U) {
                        if (a.U.length>0) {
                            var act = a.U[0];
                            if (act.elementName == 'URI') {
                                var auri =;
                                act.onTriggered = function (dispacher, event, owner) {
                                    //Do something
1 Like


Please note that you cannot rely on the minified properties such as a.U and, as these may change between versions/builds.

Is the issue that annot.getActions(); returns an empty array using Express?

Thank you Logan, I will fix the code to not use the minifield properties.

Yes , in Express annot.getActions() returns an empty array

Would you mind sharing the document you are having issues with?


of course!

test.pdf (33.6 KB)

Thanks @fbenavides !

I can reproduce your issue and will look for a fix today.

Hey again,

I found a fix and it will be fixed in the next patch, which I’ll push out either today or tomorrow. I’ll announce it in #announcements so keep an eye out!

Thank you for your patience with this one.



This was fixed in 7.3.1

1 Like