HelpBot Assistant

How can I help you?

Import/Export events in TypeScript

13 Feb 20262 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 assigning callback handlers.

viewer.importStart = (args: any) => {
  console.log('Import started', args);
};
viewer.importSuccess = (args: any) => {
  console.log('Import success', args);
};
viewer.importFailed = (args: any) => {
  console.error('Import failed', args);
};

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

viewer.exportStart = (args: any) => {
  console.log('Export started', args);
};
viewer.exportSuccess = (args: any) => {
  console.log('Export success', args);
};
viewer.exportFailed = (args: any) => {
  console.error('Export failed', args);
};

NOTE

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

See also