Syncfusion AI Assistant

How can I help you?

Import/Export events in ASP.NET Core PDF Viewer

27 Apr 20263 minutes to read

Import/export events let developers monitor and control annotation data as it flows into and out of the PDF Viewer. These events enable validation, progress reporting, audit logging, and conditional blocking of import/export operations.

Common use cases:

  • Progress UI and user feedback
  • Validation and sanitization of imported annotation data
  • Audit logging and telemetry
  • Blocking or altering operations based on business rules

Each event exposes typed event-args: ImportStartEventArgs, ImportSuccessEventArgs, ImportFailureEventArgs, ExportStartEventArgs, ExportSuccessEventArgs, and ExportFailureEventArgs that describe the operation context.

Import events

  • importStart: Triggers when an import operation starts.
  • importSuccess: Triggers when annotations are successfully imported.
  • importFailed: Triggers when importing annotations fails.

Handle import events

Example: handle import events by wiring handlers after initializing the viewer.

<div style="width:100%;height:650px">
    <ejs-pdfviewer id="pdfviewer"
                   style="height:650px"
                   documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                   resourceUrl="https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib">
    </ejs-pdfviewer>
</div>
<script>
window.onload = function () {
  var viewer = document.getElementById('pdfviewer').ej2_instances[0];
  viewer.importStart = function(args) { console.log('Import started', args); };
  viewer.importSuccess = function(args) { console.log('Import success', args); };
  viewer.importFailed = function(args) { console.error('Import failed', args); };
}
</script>

Export events

  • exportStart: Triggers when an export operation starts.
  • exportSuccess: Triggers when annotations are successfully exported.
  • exportFailed: Triggers when exporting annotations fails.

Handle export events

<div style="width:100%;height:650px">
    <ejs-pdfviewer id="pdfviewer"
                   style="height:650px"
                   documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                   resourceUrl="https://cdn.syncfusion.com/ej2/31.2.2/dist/ej2-pdfviewer-lib">
    </ejs-pdfviewer>
</div>
<script>
window.onload = function () {
  var viewer = document.getElementById('pdfviewer').ej2_instances[0];
  viewer.exportStart = function(args) { console.log('Export started', args); };
  viewer.exportSuccess = function(args) { console.log('Export success', args); };
  viewer.exportFailed = function(args) { console.error('Export failed', args); };
}
</script>

NOTE

importStart, importSuccess, and importFailed cover the lifecycle of annotation imports; exportStart, exportSuccess, and exportFailed cover the lifecycle of annotation exports.

See also