How to Delete a Specific Annotation in ASP.NET MVC PDF Viewer
14 Aug 20261 minute to read
Use the deleteAnnotationById() method to remove a specific annotation from a PDF document by its id.
Steps to delete a specific annotation
Step 1: Follow the steps provided in the Syncfusion ASP.NET MVC PDF Viewer getting started guide to create a simple PDF Viewer sample.
Step 2: Use the following code to delete a specific annotation using deleteAnnotationById(). The example deletes the first annotation in the collection; replace [0] with the index of the annotation you want to remove.
<button onclick="deleteAnnotationbyId()">deleteAnnotationbyId</button>
<div id="e-pv-e-sign-pdfViewer-div">
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf").Render()
</div>
<script>
function deleteAnnotationbyId() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.annotationModule.deleteAnnotationById(viewer.annotationCollection[0].annotationId);
}
</script><button onclick="deleteAnnotationbyId()">deleteAnnotationbyId</button>
<div id="e-pv-e-sign-pdfViewer-div">
@Html.EJS().PdfViewer("pdfviewer").ServiceUrl(VirtualPathUtility.ToAbsolute("~/PdfViewer/")).DocumentPath("https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf").Render()
</div>
<script>
function deleteAnnotationbyId() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.annotationModule.deleteAnnotationById(viewer.annotationCollection[0].annotationId);
}
</script>