Skip to content
Guides

Split Pages

The steps to split pages are as follows:

  1. Create a new CPDFDocument object for each part to be split.
  2. Add the portions of the target document that need to be split to the newly created CPDFDocument objects.

This example shows how to split pages:

java
CPDFDocument documentPart1 = CPDFDocument.createDocument(context);
// Split the first and second pages into separate sections.
documentPart1.importPages(document, new int[]{0,1}, 0);

CPDFDocument documentPart2 = CPDFDocument.createDocument(context);
// Split the third, fourth, and fifth pages into the second section.
documentPart2.importPages(document, new int[]{2,3,4}, 0);
kotlin
val documentPart1 = CPDFDocument.createDocument(context)
// Split the first and second pages into separate sections.
documentPart1.importPages(document, intArrayOf(0, 1), 0)

val documentPart2 = CPDFDocument.createDocument(context);
// Split the third, fourth, and fifth pages into the second section.
documentPart2.importPages(document, intArrayOf(2, 3, 4), 0)