Error when loading xfdf annotations

Which product are you using?
PDF.js Express

PDF.js Express Version
8.2.0

Detailed description of issue
Receiving the following error when trying to load annotations using the annotationManager.importAnnotations function:
Uncaught (in promise) TypeError: fa.getElementsByTagName is not a function
at x.P_ (webviewer-core.min.js:2413:431)
at x.WW (webviewer-core.min.js:2416:203)
at webviewer-core.min.js:419:260
at new Promise ()
at qa.FQ (webviewer-core.min.js:419:197)
at a. (view-document.php?did=175&mid=97 &id=243&hide=true:597:43)
at webviewer-core.min.js:609:402
at Array.forEach ()
at a.h.trigger (webviewer-core.min.js:609:338)
at a.Ha.JQ (webviewer-core.min.js:296:191)

Expected behaviour
Annotations to be loaded successfully on the PDF

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

Link to document
Using a local document to test

Code snippet
docViewer.addEventListener(‘documentLoaded’, async () => {
annotationManager.importAnnotations(loadXfdfString(userId, documentId));
});

const loadXfdfString = function(userId, documentId) {
return new Promise(function(resolve) {
fetch(../core/annotations-load.php?userId=${userId}&documentId=${documentId}, {
method: ‘GET’
}).then(function(res) {
if (res.status === 200) {
res.text().then(function(xfdfString) {
resolve(xfdfString);
})
} else{
alert(‘Failed to load the XFDF file…’);
}
});
});
};

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Thanks I managed to resolve the issue by changing the import code to:

docViewer.addEventListener(‘documentLoaded’, async () => {

          let result = await loadXfdfString(userId, documentId);

          await annotationManager.importAnnotations(result);

});

1 Like