Work with Pages in PDF via C++

Manage PDF pages in document programmaticaly using Aspose.PDF for C++ Library

Most popular action with Pages in C++

How to Insert pages to PDF Document Using C++

In order to add page in 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. 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

Add Page to PDF via C++


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

  1. Create a Document object with the input PDF file.

  2. Call the PageCollection collection’s Insert method with specified index.

  3. Save the output PDF using the Save method.

Add New Page to PDF


    void InsertEmptyPageAtDesiredLocation() {
    // Open document
    String _dataDir("C:\\Samples\\");

    // String for input file name
    String inputFileName("InsertEmptyPage.pdf");

    String outputFileName("InsertEmptyPage_out.pdf");

    auto document = MakeObject<Document>(_dataDir + inputFileName);

    // Insert a empty page in a PDF
    document->get_Pages()->Insert(2);

    // Save output file
    document->Save(_dataDir + outputFileName);
}