Identify annotation addition mode

28 Feb 20262 minutes to read

The Syncfusion® ASP.NET Core PDF Viewer allows you to verify how an annotation was added to the document. By inspecting the annotationAddMode property within the annotationSelect event, you can distinguish between annotations that were manually drawn by the user, imported from a data source, or pre-existing in the PDF file.

Implementation guide

Follow these steps to identify the addition mode of an annotation:

Step 1: Initialize a PDF Viewer project by following the ASP.NET Core getting started guide.

Step 2: Subscribe to the annotationSelect event and log the annotationAddMode property from the event arguments.

The following example demonstrates this implementation across standalone and server-backed configurations:

<div style="width:100%;height:600px">
    <ejs-pdfviewer  id="pdfviewer"
                    style="height:600px"
                    documentPath="https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf"
                    resourceUrl="https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib">
    </ejs-pdfviewer>
</div>

<script>
    const viewer = document.getElementById("pdfviewer").ej2_instances[0];
    viewer.annotationSelect = function annotationSelected(args) {
        console.log(args.annotationAddMode);
    }
</script>
<div style="width:100%;height:600px">
    <ejs-pdfviewer id="pdfviewer"
                   style="height:600px"
                   documentPath="https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf"
                   serviceUrl="/api/PdfViewer">
    </ejs-pdfviewer>
</div>

<script>
    const viewer = document.getElementById("pdfviewer").ej2_instances[0];
    viewer.annotationSelect = function annotationSelected(args) {
        console.log(args.annotationAddMode);
    }
</script>