Insert Pages into PDF
Contents
[
Hide
]
Insert pages into a PDF
The Java sample inserts pages 1 and 2 from the secondary document after page 2 of the target PDF.
Steps
- Create a
PdfFileEditorinstance. - Choose the insertion point in the target document.
- Select the page numbers to copy from the source document.
- Call
insertwith the target file, insertion point, source file, page array, and output file. - Save the updated PDF.
Java example
public static void insertPagesIntoPdf(Path inputFile, Path sampleFile, Path outputFile) {
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.insert(inputFile.toString(), 2, sampleFile.toString(), new int[] {1, 2}, outputFile.toString());
}