Manage annotations effectively with our API
In addition to managing annotations with the create, update, and delete APIs, we also provide events that let you intercept annotation changes made through the user interface (UI) or synced from the server.
Event | Use case |
---|---|
annotations.load |
Triggered when annotations are loaded from the document. |
annotations.willChange |
Triggered before a user modifies an annotation through the UI (for example, by drawing). |
annotations.change |
Triggered when annotations change due to a user action or API call. |
annotations.create |
Triggered when new annotations are created. |
annotations.update |
Triggered when existing annotations are updated. |
annotations.delete |
Triggered when annotations are deleted. |
instance.addEventListener("annotations.load", loadedAnnotations => { console.log(loadedAnnotations); }); instance.addEventListener("annotations.willChange", event => { if (event.reason === PSPDFKit.AnnotationsWillChangeReason.DRAW_START) { console.log("The user is drawing..."); } }); instance.addEventListener("annotations.change", () => { console.log("Something in the annotations has changed."); }); instance.addEventListener("annotations.create", createdAnnotations => { console.log(createdAnnotations); }); instance.addEventListener("annotations.update", updatedAnnotations => { console.log(updatedAnnotations); }); instance.addEventListener("annotations.delete", deletedAnnotations => { console.log(deletedAnnotations); });