Skip to content
Guides

Insert Pages

Insert a blank page or pages from other PDFs into the target document.

Insert Blank Pages

This example shows how to insert a blank page:

swift
// The `InsertPage` method allows specifying an image path, and when the image path is empty, it inserts a blank page.
document?.insertPage(CGSize(width: 595, height: 852), withImage: "", at: 0)
objective-c
// The `InsertPage` method allows specifying an image path, and when the image path is empty, it inserts a blank page.
[document insertPage:CGSizeMake(595, 852) withImage:"" atIndex:0]

Insert Pages from other PDFs

This example shows how to pages from other PDFs:

swift
let insertDocument = CPDFDocument(url: URL(fileURLWithPath: "OtherPDF.pdf"))
var indexSet = IndexSet()
indexSet.insert(0)

document?.importPages(indexSet, from: insertDocument, at: 0)
objective-c
CPDFDocument *insertDocument = [[CPDFDocument alloc] initWithURL:[NSURL fileURLWithPath:@"OtherPDF.pdf"]];
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
[indexSet addIndex:0];

[document importPages:indexSet fromDocument:insertDocument atIndex:0];