Merge PDF files in C++

Combine related PDF files into one document by appending their page collections.

Merge two PDF documents

  1. Open both input files as Document objects.
  2. Append the pages of the second document to the first with PageCollection::Add().
  3. Save the result with Document::Save().
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/PageCollection.h>

using namespace System;
using namespace Aspose::Pdf;

void MergeDocuments(String inputFile1, String inputFile2, String outputFile) {
    auto document1 = MakeObject<Document>(inputFile1);
    auto document2 = MakeObject<Document>(inputFile2);
    document1->get_Pages()->Add(document2->get_Pages());
    document1->Save(outputFile);
}