Concatenate Two PDF Files
Contents
[
Hide
]
Concatenate two PDF files
This article maps directly to the mergePdfDocuments example in PdfFileEditorExamples.java.
Steps
- Create a
PdfFileEditorinstance. - Pass the two input file paths as a string array.
- Call
concatenatewith the array and output file path. - Save the merged PDF.
public static void mergePdfDocuments(Path firstInputFile, Path secondInputFile, Path outputFile) {
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.concatenate(new String[] {firstInputFile.toString(), secondInputFile.toString()}, outputFile.toString());
}