Delete a specific annotation in ASP.NET Core PDF Viewer

28 Feb 20261 minute to read

Remove specific annotations programmatically using the deleteAnnotationById() method. This allows you to implement custom deletion workflows based on annotation identifiers or user interactions.

Remove annotations programmatically

Step 1: Follow the Syncfusion ASP.NET Core PDF Viewer getting started guide to set up a basic PDF Viewer sample.

Step 2: Add a button and script to delete an annotation by its unique ID. The following example demonstrates how to remove the first annotation from the viewer’s collection:

<button onclick="deleteAnnotationbyId()">deleteAnnotationbyId</button>

<div style="width:100%;height:600px">
    <ejs-pdfviewer
        id="pdfviewer"
        documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
    </ejs-pdfviewer>
</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 style="width:100%;height:600px">
    <ejs-pdfviewer
        id="pdfviewer"
        serviceUrl='/Index'
        documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
    </ejs-pdfviewer>
</div>

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

View sample on GitHub