Skip to content

访问注释

访问注释列表和注释对象的步骤如下:

  1. 获取页面对象。

  2. 从页面对象中访问注释列表。

  3. 遍历列表中的每个注释对象。

以下示例演示如何访问注释:

tsx
// 获取 PDF 文档的总页数
const pageCount = await pdfReaderRef!.current!._pdfDocument.getPageCount();
let allAnnotations: CPDFAnnotation[] = [];
for (let i = 0; i < pageCount; i++) {
  // 获取对应页码的页面对象
  const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(i);
  // 获取该页面上的所有注释
  const annotations = await page?.getAnnotations();
  if (annotations) {
    allAnnotations = allAnnotations.concat(annotations);
  }
}