Guides
Delete Pages
Delete specified pages from the current document. The steps to delete pages are as follows:
- Specify the collection of page indices to delete.
- Call the delete pages interface.
- Refresh the document to apply the changes.
The following example demonstrates how to delete pages:
tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({})}
/>
// Delete pages 1, 2, and 3 (page indices start from 0)
const deleteResult = await pdfReaderRef.current?._pdfDocument.removePages([0, 1, 2]);
if (deleteResult) {
// Refresh the page to apply the deletion effect
await pdfReaderRef.current?.reloadPages2();
}