Concatenate Multiple PDF Files
Contents
[
Hide
]
Concatenate PDF files
The Java sample merges two files by passing them to the array-based concatenate overload.
Steps
- Create a
PdfFileEditorinstance. - Build a string array with the input PDF paths.
- Call
concatenatewith the input array and output file path. - Save the merged document.
public static void mergePdfDocuments(Path firstInputFile, Path secondInputFile, Path outputFile) {
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.concatenate(new String[] {firstInputFile.toString(), secondInputFile.toString()}, outputFile.toString());
}
To merge more than two files, extend the string array passed to concatenate.