Check If a Document Contains Annotations

To check if a document contains annotations, use Instance#getAnnotations to retrieve the annotations for each page. Then, flatten the array and evaluate the resulting array to see whether or not it’s empty:

  // Your configuration.
}).then(async (instance) => {
  const pagesAnnotations = await Promise.all(
      length: instance.totalPageCount
    }).map((_, pageIndex) => instance.getAnnotations(pageIndex))

  const allAnnotations = pagesAnnotations
    .map((pageList) => pageList.toJS())

  const hasAnnotations = allAnnotations.length > 0;

This has been tested with PSPDFKit for Web 2020.5.1.