Remove PDF annotations using Javascript

Many users will remove or delete annotations using the WebViewer UI. The simplest way to do this with the WebViewer UI is to select the annotation and choose the delete/trash icon in the popup modal.

Apryse Docs Image

Programmatically

Annotations can also be deleted programmatically. You'll want to make sure that the annotations have already been loaded in the viewer.

For example to remove it immediately after the annotations are loaded then use the annotationsLoaded event:

1WebViewer(...)
2 .then(instance => {
3 const { documentViewer, annotationManager } = instance.Core;
4
5 documentViewer.addEventListener('annotationsLoaded', () => {
6 const annots = annotationManager.getAnnotationsList();
7
8 // remove annotations
9 annotationManager.deleteAnnotations(annots);
10 });
11 });

Customize or modify a PDF before saving
Full sample code demonstrating how to customize document save/download. In the example, annotations are deleted for rerendering and flattened before saving.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales