Merge Documents

This demo uses the DevExpress PDF Document API to merge multiple PDFs into a single file. You can merge predefined sample files or supply your own documents. To do the latter, select Upload a File in the file selection drop-down menu and upload files one at a time.

Click the Merge Documents button to merge files and download the result.

Sample document
Sample_Main.pdf
Sample_Alternative.pdf



using DevExpress.Pdf;

Stream MergeDocuments(IEnumerable<Stream> documentStreams) {
    using var processor = new PdfDocumentProcessor();

    processor.CreateEmptyDocument();

    foreach(var stream in documentStreams)
        processor.AppendDocument(stream);

    var outputStream = new MemoryStream();

    processor.SaveDocument(outputStream);

    outputStream.Position = 0;
    return outputStream;
}