Articles in this section
Category / Section

How to update/delete specific annotations in React PDF Viewer?

3 mins read

This article explains how to edit and delete specific annotations in React PDF Viewer. Delete a specific annotation using the deleteAnnotationById() method. This method is used to delete a specific annotation using its ID.

Refer to the following code to delete a specific annotation.

<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>

Sample link:

https://stackblitz.com/edit/react-lbkk6p?file=public%2Findex.html

Update the specific annotation programmatically using the editAnnotation() method.

 

Refer to the following code to edit a specific annotation.

<button onclick="editAnnotation()">Edit Annotation</button>
 
<script>
// Edit the annotation.
function editAnnotation() {
  var pdfViewer = document.getElementById('container').ej2_instances[0];
  pdfViewer.annotationModule.selectAnnotation(pdfViewer.annotationCollection[0].annotationId);
  pdfViewer.annotationCollection[0].opacity = "0.5";
  pdfViewer.annotationCollection[0].fillColor = "blue";
  pdfViewer.annotationModule.editAnnotation(pdfViewer.annotationCollection[0]);
}
</script>

Sample link:

https://stackblitz.com/edit/react-ywbpmk?file=public%2Findex.html

Conclusion

I hope you enjoyed learning about how to update/delete specific annotations in React PDF Viewer.

You can refer to our React PDF Viewer’s feature tour page to learn about its other groundbreaking feature representations. You can also explore our React PDF Viewer documentation to understand how to present and manipulate data.

For current customers, you can check out our React components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our React PDF Viewer and other React components.

If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied