PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
The ComPDF React Native SDK provides APIs to delete selected annotations. The steps to delete annotations are as follows:
Example code:
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({})}
/>
// Get the page object at a specific index
const page = pdfReaderRef?.current?._pdfDocument.pageAtIndex(0);
// Get all annotations on the page
const annotations = await page?.getAnnotations();
if (annotations[0]) {
await page.removeAnnotation(annotations[0]);
}
// Or use this shortcut
pdfReaderRef?.current?._pdfDocument.removeAnnotation(annotations[0]);Alternatively, you can remove all annotations from the current document by calling the removeAllAnnotations() method.
Example code:
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({
})}/>
const removeResult = await pdfReaderRef.current?.removeAllAnnotations();Note: This method does not delete hyperlink annotations.