The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

Merge Documents

  • 2 min 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 require a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.