PDF File Merger for C++

Merge PDF documents in a browser without needing Adobe Acrobat or Automation - C++.

How to Merge PDF files Using C++ Library

In order to merge PDF file, we’ll use Aspose.PDF for C++ API which is a feature-rich, powerful and easy-to-use document manipulation API for cpp platform. Our C++ Library can convert a document from any supported download format to any supported save format. Aspose.PDF for C++ library provides fairly universal solutions that will help you solve the tasks of converting documents. Aspose.PDF supports the largest number of popular document formats, both for loading and saving. Draw your attention that the current section describes only popular conversions. The current page provides information about converting format to format. However, there are many combinations for converting your files. For a complete list of supported formats, see the section Supported File Formats. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

Merge PDF files via C++

You need Aspose.PDF for C++ to try the code in your environment.

  1. Open first document.
  2. Open second document.
  3. Add pages of second document to the first.
  4. Save concatenated output file

Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit, and Linux 64 bit.
  • Development environment like Microsoft Visual Studio.
  • Aspose.PDF for C++ DLL referenced in your project.

C++ - example code to merge PDF files.

    // String for path name
    String _dataDir("C:\\Samples\\");

    // String for input file name
    String pdfDocumentFileName1("Concat1.pdf");
    String pdfDocumentFileName2("Concat2.pdf");
    String outputFileName("ConcatenatePdfFiles.pdf");

    // Open document
    auto pdfDocument1 = MakeObject<Document>(_dataDir + pdfDocumentFileName1);
    auto pdfDocument2 = MakeObject<Document>(_dataDir + pdfDocumentFileName2);

    // Add pages of second document to the first

    // Save concatenated output file