Skip to content
ComPDF
DemoSampleAPI ReferenceFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Guides

Extract Pages

This example shows how to extract pages:

java
CPDFDocument extractDocument = CPDFDocument.createDocument(context);
// Extract the first page of the original document and save it in a new document.
extractDocument.importPages(document, new int[]{0}, 0);
kotlin
val extractDocument = CPDFDocument.createDocument(context)
// Extract the first page of the original document and save it in a new document.
extractDocument.importPages(document, intArrayOf(0), 0)

When the document is bound and displayed through CPDFReaderView, after modifying the document pages, you need to call the following method to refresh the view so that the changes take effect immediately:

java
cpdfReaderView.reloadPages();