Created
June 18, 2020 00:58
-
-
Save aspose-com-gists/71e67641b18c8933a417a30f000ee63f to your computer and use it in GitHub Desktop.
Merge PDF Files using Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create PdfFileEditor object | |
PdfFileEditor fileEditor = new PdfFileEditor(); | |
// First PDF file | |
InputStream stream1 = new FileInputStream("file1.pdf"); | |
// Second PDF file | |
InputStream stream2 = new FileInputStream("file2.pdf"); | |
// OutputStream for merged PDF | |
OutputStream outstream = new FileOutputStream("merged.pdf"); | |
// Merge PDF files | |
fileEditor.concatenate(stream1, stream2, outstream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create PdfFileEditor object | |
PdfFileEditor fileEditor = new PdfFileEditor(); | |
String[] files = new String[] { "file1.pdf", "file2.pdf", "pdf3.pdf" }; | |
// Merge multiple PDF files | |
fileEditor.concatenate(files, "merged-pdf.pdf"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create PDF editor | |
PdfFileEditor fileEditor = new PdfFileEditor(); | |
// Merge two PDF files | |
fileEditor.concatenate("file1.pdf", "file2.pdf", "merged-pdf.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment