Search results

Delete a specific annotation in React PDF Viewer component

08 Dec 2021 / 1 minute to read

The PDF Viewer library allows you to delete a specific annotation from a PDF document. Deleting a specific annotation can be done using the deleteAnnotationById() method. This method is used to delete a specific annotation using its id.

The following steps are used to delete a specific annotation from PDF Document.

Step 1: Follow the steps provided in the link to create a simple PDF Viewer sample.

Step 2: Use the following code snippet to delete a specific annotation using deleteAnnotationById() method.

Copied to clipboard
<button onclick="deleteAnnotationbyId()">Delete Annotation by ID</button>

<script>
  // Delete Annotation by id.
  function deleteAnnotationbyId() {
  var viewer = document.getElementById('container').ej2_instances[0];
  viewer.annotationModule.deleteAnnotationById(viewer.annotationCollection[0].annotationId);
  }
</script>

Find the sample, how to delete a specific annotation using deleteAnnotationById