Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created June 18, 2020 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/71e67641b18c8933a417a30f000ee63f to your computer and use it in GitHub Desktop.
Save aspose-com-gists/71e67641b18c8933a417a30f000ee63f to your computer and use it in GitHub Desktop.
Merge PDF Files using Java
// 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);
// 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");
// 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