Search results

Clear the annotations

06 Jun 2023 / 1 minute to read

To clear all the annotations in a PDF document using the Syncfusion PDF Viewer, you can use the deleteAnnotations method. This method is used to clear all the annotations present in the currently loaded document.

Here is an example of how you can clear all the annotations present in the currently loaded document:

Copied to clipboard
 <button id="deleteAnnotations">Delete Annotations</button>
Copied to clipboard
//clear Annotations.
document.getElementById('deleteAnnotations').addEventListener('click',()=> {
  viewer.deleteAnnotations();
})

We can also delete specific annotations with the deleteAnnotationById() method. This method is used to delete a specific annotation using its id.

Here is an example of how you can delete specific annotations with the deleteAnnotationById method:

Copied to clipboard
 <button id="deleteAnnotationbyId">Delete Annotation By Id</button>
Copied to clipboard
//Delete Annotation by ID.
document.getElementById('deleteAnnotationbyId').addEventListener('click', () => {
    viewer.annotationModule.deleteAnnotationById(
      viewer.annotationCollection[0].annotationId
    );
});

Find the sample how to clear annotations using deleteAnnotations