Clear existing annotation form the WebViewer

WebViewer Version: ‘8.6.1’

Do you have an issue with a specific file(s)? XOD
Can you reproduce using one of our samples or online demos? not sure
Are you using the WebViewer server? no
Does the issue only happen on certain browsers?no
Is your issue related to a front-end framework? no
Is your issue related to annotations?yes

Please give a brief summary of your issue:
(Think of this as an email subject)

I need to clear the annotation which i am loading for the previous documents.
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

I am using the WebViewer to load xod documents and their respective annotation through XFDF data.
I am using the code

  documentViewer.on("documentLoaded", async () => {
    annotationManager.importAnnotations(document.xfdfData)
  });

But when I am switching the XOD documents the annotations of the previously opened documents are also repeated. I need a way so that annotation of the respective documents are only show in the viewer

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

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:

Hi Indranath,

The event documentLoaded will trigger whenever any document is loaded. In this case, it is causing your first documents xfdf data to be added on every document load.

If you want to trigger the event only once, you can do this

  documentViewer.on("documentLoaded", async () => {
    annotationManager.importAnnotations(document.xfdfData)
  }, { once: true });

Docs: PDFTron WebViewer Class: DocumentViewer

Best Regards,
Ahmad Moaaz
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

1 Like