On this page
Guides
Merge Pages
The steps to merge pages are as follows:
- Create a blank PDF document.
- Open the PDF document containing the pages to be merged.
- Select all the pages to be merged and combine them into the same document.
This example shows how to merge pages:
java
CPDFDocument documentForMerge = CPDFDocument.createDocument(context);
CPDFDocument document1 = new CPDFDocument(context);
document1.open(pdfFile);
CPDFDocument document2 = new CPDFDocument(context);
document2.open(pdfFile);
documentForMerge.importPages(document1, 0, document1.getPageCount() - 1, document.getPageCount());
documentForMerge.importPages(document2, 0, document2.getPageCount() - 1, document.getPageCount());
kotlin
val documentForMerge = CPDFDocument.createDocument(context)
val document1 = new CPDFDocument(context)
document1.open(pdfFile);
val document2 = new CPDFDocument(context)
document2.open(pdfFile)
documentForMerge.importPages(document1, 0, document1.pageCount - 1, document.pageCount);
documentForMerge.importPages(document2, 0, document2.pageCount - 1, document.pageCount);