Example
// Listen for view state changes
instance.addEventListener("viewState.change", (viewState, previousViewState) => {
console.log("View state changed:", viewState.toJS());
});
// Listen for annotation creation
instance.addEventListener("annotations.create", (annotations) => {
console.log("New annotations created:", annotations.toJS());
});
// Listen for page navigation
instance.addEventListener("viewState.currentPageIndex.change", (pageIndex) => {
console.log("Current page changed to:", pageIndex);
});
Interfaces
AnnotationNoteHoverEventAnnotationNotePressEventAnnotationPresetsUpdateEventAnnotationsBlurEventAnnotationsCopyEventAnnotationsCutEventAnnotationsDuplicateEventAnnotationsFocusEventAnnotationsPasteEventAnnotationsPressEventAnnotationsTransformEventAnnotationsWillChangeEventCommentsMentionEventCropAreaChangeStartEventCropAreaChangeStopEventEventNameToHandlerMapFormFieldValuesDidSaveEventHistoryChangeEventHistoryRedoEventHistoryUndoEventHistoryWillChangeEventPagePressEventPageRenderErrorEventSaveStateChangeEventSearchTermChangeEventTextAnnotationEditorStateChangeEventTextLinePressEvent
Type Aliases
AnnotationsCreateEventAnnotationsDeleteEventAnnotationsDidSaveEventAnnotationSelectionChangeEventAnnotationsLoadEventAnnotationsUpdateEventAnnotationsWillSaveEventBookmarksCreateEventBookmarksDeleteEventBookmarksLoadEventBookmarksUpdateEventCommentsCreateEventCommentsDeleteEventCommentsLoadEventCommentsUpdateEventContentEditorStateChangeEventDocumentComparisonUIEndEventDocumentComparisonUIStartEventFormFieldsCreateEventFormFieldsDeleteEventFormFieldsLoadEventFormFieldsUpdateEventFormFieldValuesUpdateEventFormsWillSubmitEventInkDrawingEventInkSignatureCreateEventInkSignatureDeleteEventInkSignatureUpdateEventSearchStateChangeEventStoredSignatureCreateEventStoredSignatureDeleteEventStoredSignatureUpdateEventViewStateCurrentPageIndexChangeEventViewStateZoomChangeEvent
The
Eventsnamespace contains all the event types that can be used with theaddEventListener()method. These events provide a comprehensive way to monitor and respond to changes within the PDF viewer.Event Handler Types
Each event has a corresponding event listener type that defines the expected function signature. These types ensure type safety when registering event listeners and provide clear documentation of the parameters each event listener receives.
Event Lifecycle
Many events follow a lifecycle pattern:
For example, with annotations:
annotations.willSave→annotations.change→annotations.didSave