Examples

Merge PDF in Java

DynamicPDF makes Merging PDFs together easy. Here are some examples on the basic steps and how to specify what data is merged by using merge options.

How to Merge PDF Files

Below are the steps and sample code to merge PDF files with and without options.

Steps to Merge PDFs

  1. Create a MergeDocument object using the static Merge method, passing in two PDFs to be merged.
  2. Call the Draw method to save the merged PDF.

Sample code - Java

MergeDocument document = MergeDocument.Merge("DocumentA.pdf", "DocumentB.pdf");
document.Draw("Merged Output.pdf");

If you have additional PDFs to merge, you can append them by calling the Append method.

Sample code with Append - Java

MergeDocument document =  new MergeDocument("DocumentA.pdf");
        
document.append("Append DocB.pdf", 1, 2);
document.append("Append DocC.pdf");
        
document.draw("Appended Output.pdf");

Getting Started

DynamicPDF Merger Information

More information can be found here:

Available in Other Platforms

DynamicPDF Merger PDF Library is available for Java and COM/AxtiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!