Delete Pages from PDF in C++

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

Delete pages from PDF

Delete pages 2 and 4.

  1. Create PdfFileEditor.
  2. Delete the selected pages with PdfFileEditor::Delete().
#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 DeletePagesFromPdf(String inputFile, String outputFile)
{
    auto pdfEditor = MakeObject<PdfFileEditor>();
    pdfEditor->Delete(inputFile, MakeArray<int32_t>({2, 4}), outputFile);
}
} // namespace  Facades::Examples::PDF_FileEditor