Delete an annotation in the ASP.NET MVC PDF Viewer

23 Oct 20251 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().

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