Delete All Annotations

There’s no specific command to delete all annotations in a document at once. However, this can be achieved by iterating the pages, retrieving all the annotations, and calling PSPDFKit.Instance#delete() on their IDs:

PSPDFKit.load(configuration).then((instance) => {
  (async () => {
    const pagesAnnotations = await Promise.all(
      Array.from({
        length: instance.totalPageCount
      }).map((_, pageIndex) => instance.getAnnotations(pageIndex))
    );
    const annotationIds = pagesAnnotations.flatMap((pageAnnotations) =>
      pageAnnotations.map((annotation) => annotation.id).toArray()
    );
    await instance.delete(annotationIds);
  })();
});

This has been tested with PSPDFKit for Web 2020.5.0