Remove PDF annotations using JavaScript
In addition to an API for editing annotations, we also provide an API for removing those annotations directly on the client. Following the optimistic UI approach, the changes will be instantly visible in the UI, but they aren’t persisted until the annotations are saved.
To remove annotations, use Instance#delete
. This API requires the annotation IDs only:
PSPDFKit.load(configuration).then(async (instance) => { const annotations = await instance.getAnnotations(0); const annotation = annotations.get(0); await instance.delete(annotation); console.log("Annotation deleted."); });
Once annotations have been edited, they’ll need to be persisted. This is done by saving them. Save them to external storage or embed them into the document. They can also be exported to XFDF or Instant JSON. If you’re using Web SDK with Document Engine, they can be synced with the backend.