Import and Export annotation as object

2 Dec 20221 minute to read

The PDF Viewer library allows you to import annotations from objects or streams instead of loading it as a file. To import such annotation objects, the PDF Viewer control must export the PDF annotations as objects using the ExportAnnotationsAsObject() method. Only the annotations objects that are exported from the PDF Viewer can be imported.

The following steps are used to import and export annotation as object.

Step 1: Follow the steps provided in the link to create a simple PDF Viewer sample.

Step 2: Use the following code snippet to perform import and export annotation.

<button type="button" onclick="exportAnnotation()">Export Annoatation</button>
<button type="button" onclick="importAnnotation()">Import Annoatation</button>

    var exportObject;
    //Export annotation as object.
    function exportAnnotation() {
        var viewer = document.getElementById('pdfViewer').ej2_instances[0];
        viewer.exportAnnotationsAsObject().then(function (value) {
            exportObject = value
    //Import annotation that are exported as object.
    function importAnnotation() {
        var viewer = document.getElementById('pdfViewer').ej2_instances[0];

Find the Sample, how to import and export annotation as object