Insert Pages into PDF in C++

Use PdfFileEditor for this task. The examples below retain the original C++ code and API Reference steps.

Insert pages into PDF

Insert pages 1 and 2 from sampleFile after page 2 of the input document.

  1. Create PdfFileEditor.
  2. Insert source pages with PdfFileEditor::Insert().
#include <Aspose.PDF.Cpp/Facades/PdfFileEditor.h>
#include <system/array.h>
#include <system/string.h>

namespace  Facades::Examples::PDF_FileEditor
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;

void InsertPagesIntoPdf(String inputFile, String sampleFile, String outputFile)
{
    auto pdfEditor = MakeObject<PdfFileEditor>();
    pdfEditor->Insert(inputFile, 2, sampleFile, MakeArray<int32_t>({1, 2}), outputFile);
}
} // namespace  Facades::Examples::PDF_FileEditor