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.

Extract Pages

This example shows how to extract pages:

swift
var indexSet = IndexSet()
indexSet.insert(0)

let extractDocument = CPDFDocument()
// Extract the first page of the original document and save it in a new document.
extractDocument?.importPages(index, from: document, at: 0)
objective-c
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
[indexSet addIndex:0];

CPDFDocument *extractDocument = [[CPDFDocument alloc] init];
// Extract the first page of the original document and save it in a new document.
[extractDocument importPages:indexSet fromDocument:document atIndex:0];