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.
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}
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
WebViewer({
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.fr;
act.onTriggered = function (dispacher, event, owner) {
//Do something
}
}
}
}
});
});
});
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!