Skip to main content
A newer version of this page is available. .

Merge Documents

  • 2 minutes to read

The PDF Document API component allows you to merge multiple PDF documents.

Use API from the table below to complete the task.

API Description
PdfDocumentProcessor.CreateEmptyDocument Creates an empty document. You can specify a file path or a stream to pass the document. The document’s content is not kept in memory during the merge.
PdfDocumentProcessor.AppendDocument Appends the content of one document to another. All additional content (interactive forms, bookmarks,hyperlinks, file attachments, etc.) is copied to the resulting file. The original document’s content is retained.

When the merge is completed, you don’t need to save this document since it is written during the process. Dispose of the PdfDocumentProcessor instance to close the document.

This example illustrates how to use the PDF Document API component to merge pages of two separate PDF documents into a single PDF document.

using DevExpress.Pdf;

namespace PdfMergeExample {

    class Program {
        static void Main(string[] args) {

            using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor()) {
                pdfDocumentProcessor.CreateEmptyDocument("..\\..\\docs\\Merged.pdf");
                pdfDocumentProcessor.AppendDocument("..\\..\\docs\\TextMerge1.pdf");
                pdfDocumentProcessor.AppendDocument("..\\..\\docs\\TextMerge2.pdf");             
            }
        }
    }
}

Important

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use these examples in production code.