Guides
编辑注释
ComPDF React Native SDK 提供 API,可修改注释属性以更新注释的外观和内容。以下示例展示了如何修改注释的颜色、透明度和内容:
tsx
const document = pdfReaderRef?.current?._pdfDocument;
const page = document.pageAtIndex(0);
const annotations = await page?.getAnnotations();
const annotation = annotations![0];
annotation.update({
title: `Updated ${annotation.type} Annotation`,
content: `This ${annotation.type} annotation has been updated.`,
color: "#FF33AA",
alpha: 180,
});
await document.updateAnnotation(annotation);更多可修改的属性请参考各注释类的定义,例如 CPDFNoteAnnotation、CPDFMarkupAnnotation 等。
此外,ComPDF SDK 还提供了修改注释属性的面板弹窗。可以通过调用以下 API 显示注释属性编辑面板:
tsx
await pdfReaderRef?.current?.showAnnotationPropertiesView(annotation);