Check if document contains annotations

Q: How can I check if a document contains any annotation?

A: This can be done by using [PSPDFKit.Instance.getAnnotations][] to retrieve the annotations for each page, then flattening the array and finally evaluating if the resulting array is empty or not.

PSPDFKit.load({ 
  // your configuration
   })
    .then(async instance => {
      const pagesAnnotations = await Promise.all(
        Array.from({ length: instance.totalPageCount }).map((_, pageIndex) =>
          instance.getAnnotations(pageIndex)
        )
      );

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

      const hasAnnotations = allAnnotations.length > 0;
    });

This has been tested with PSPDFKit for Web 2020.5.1.