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:

java
CPDFDocument document = new CPDFDocument(context);
document.open(pdfPath);
// Insert after the first page.
int pageIndex = 1; 
float pageWidth = 595F;
float pageHeight = 842F;
document.insertBlankPage(pageIndex, pageWidth, pageHeight);
kotlin
val document = CPDFDocument(context)
document.open(pdfPath)
// Insert after the first page.
val pageIndex = 1 
val pageWidth = 595F
val pageHeight = 842F
document.insertBlankPage(pageIndex, pageWidth, pageHeight)

Insert Pages from other PDFs

This example shows how to insert pages from other PDFs:

java
CPDFDocument document2 = new CPDFDocument(context);
document2.open(pdfPath);
document.importPages(document2, new int[]{0}, 1);
kotlin
val document2 = CPDFDocument(context)
document2.open(pdfPath)
document.importPages(newDocument, intArrayOf(0), 1)