Skip to main content

Events

viewer.on subscribes to one event and returns a function that removes that listener. The payload is the only argument.

const stop = viewer.on("open", ({ document }) => {
document.info();
});
EventWhen it firesPayload
loadingopen has started{ name? }
openThe file is open{ document }
closeThe file is closed{}
changeAn edit is applied{ command, result }
selectionThe selection changesSelectionState or null
highlightA highlight is applied or cleared{ color, text, ranges, anchor, focus }
annotationA comment is attached to a highlight{ id, text, quote, ranges, anchor, focus }
replaceImageThe host can swap the selected image{ id, page, file }
errorOpen or a command fails{ error }
exportThe edited file is exported{ name, blob }
zoomThe zoom changes{ zoom }
themeThe palette on screen changes{ theme }
viewModeThe mode changes{ mode } is live, track, or view
searchA search moves to a hit{ query, hitCount, hitIndex }

hitIndex is zero-based, or -1 when there are no hits. highlight.color is null when the highlight was cleared.