annotManager.exportAnnotations stops working randomly

Product: pdftron/pdfnet-node

Product Version: 9.0.0-3

Please give a brief summary of your issue:
annotManager.exportAnnotations() stops working sometimes with no error and the code that follows stops being hit.

Please describe your issue and provide steps to reproduce it:
The following code block gets annotations from whatever file is present and saves them off. On occasion annotManager.exportAnnotations() just stops working and all other code following is not executed. No error is thrown and there is no obvious difference in the files that would cause this. This behavior is pretty random and may or may not happen to the same file. I was able to reproduce this in all of our environments.

Please provide a link to a minimal sample where the issue is reproducible:

const uploadAnnotatedFile = async (): Promise => {
const { instance, data } = pdfInstance;
const { docViewer, annotManager } = instance;
const doc = docViewer.getDocument();
debugger;
const annotations = await annotManager.exportAnnotations();
if (annotations !== data) {
const fileData = await doc.getFileData({
xfdfString: annotations,
});
const fileName = await doc.getFilename();
dispatch(uploadEditedPdf({ data: fileData, fileName: fileName, xfdfString: annotations }));
}
};

Hello there.

Thanks for contacting WebViewer’s support.

Could you confirm what WebViewer’s version you are using? You can read more on how to check your WebViewer’s version here: https://www.pdftron.com/documentation/web/faq/version-number/

Best Regards,
Diego Felix
Web Software Developer
PDFTron Systems, Inc.
www.pdftron.com

CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.

My WebViewer’s version is 7.2.0

Hello there.

I wasn’t able to reproduce the issue. I’ve tried to run the code below (which runs the core of your code 100 times) and it worked every time.

Webviewer({
  initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
  path: '/lib',
}, document.getElementById('viewer')).then(async (instance) => {
  const { docViewer, annotManager } = instance;

  docViewer.on('documentLoaded', async () => {
    console.log('Beginning')

    for (let i = 0; i < 100; i++) {
      console.log(`Loop beginning ${i+1}`)
      const doc = docViewer.getDocument();

      const annotations = await annotManager.exportAnnotations();
      console.log(annotations.length)
      await doc.getFileData({
        xfdfString: annotations,
      });
      await doc.getFilename();

      console.log(`Loop end ${i+1}`)
    }

    console.log('End')
  })
});

My setup is Chrome (latest version) and WebViewer 7.3 (latest 7.3 version).

Can you run the same code snippet on your end and see if there is an issue with it? If there is not, I would recommend updating your WebViewer version (It can be the case that this issue was already fixed) and checking how your code is hooked up with the rest of the application’s code (The problem might be somewhere else).

Let me know how this works for you and if you have any further questions.

Best Regards,
Diego Felix
Web Software Developer
PDFTron Systems, Inc.
www.pdftron.com

CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.