Here is a sample Java program that shows how to copy pages from one PDF document to another using Qoppa’s PDF library jPDFProcess. The sample can be adapted to work with Qoppa’s jPDFAssemble by simply replacing the class “PDFDocument” with “PDFAssemble”.

In this sample, we’re copying the pages from an existing PDF to a new PDF but the target PDF does not need to be a new document.

// load input document
PDFDocument inputPDF = new PDFDocument(C:\\test\\input.pdf, null);
// create new document
PDFDocument ouputPDF = new PDFDocument();
// loop through existing document pages
for (int i = 0; i < inputPDF.getPageCount(); i++) 
 // append page to new document
// save new document