Join Two or More PDFs
IronPDF can combine the contents of multiple PDF documents. A common use for this feature is in attaching cover pages to new or existing PDFs. Other possible uses include bundling related documents together into one file for convenient printing and transport.
The code example above uses the
PdfDocument.merge method on two
PdfDocument objects that were both rendered from HTML markup. The result of the invocation is a new
PdfDocument produced by appending the content of the latter
PdfDocument to the end of the former one.
To combine more than three PDF documents, first create a list containing the required
PdfDocument objects, and then pass the list as a single argument to the
List<PdfDocument>pdfs = new ArrayList<>(); pdfs.add(pdfA); pdfs.add(pdfB); pdf.add(pdfC); pdf.add(pdfD); PdfDocument merged = PdfDocument.merge(pdfs);