Guides
渲染注释外观
ComPDF React Native SDK 提供了渲染注释外观的 API,无需显示 PDF 查看器即可生成注释的可视化效果。这对于需要单独处理注释图像的场景非常有用,例如将注释作为独立元素进行展示或保存。
以下示例展示了如何渲染注释外观:
tsx
const page = pdfReaderRef.current?._pdfDocument.pageAtIndex(0);
const annotations = await page?.getAnnotations();
const annotation = annotations?.[0];
if (annotation) {
const base64 = await pdfReaderRef.current?._pdfDocument.renderAnnotationAppearance(
annotation,
{
scale: 4,
compression: CPDFPageCompression.PNG,
}
);
}