Delete Images from PDF in C++

Contents
[ ]

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

Delete image

Delete image index 1 from page 1.

  1. Create PdfContentEditor.
  2. Bind the PDF input with Facade::BindPdf().
  3. Delete the images with PdfContentEditor::DeleteImage().
  4. Save the resulting PDF with PdfContentEditor::Save().
#include <Aspose.PDF.Cpp/Facades/PdfContentEditor.h>
#include <system/array.h>
#include <system/string.h>

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

void DeleteImage(String inputFile, String outputFile)
{
    auto editor = MakeObject<PdfContentEditor>();

    editor->BindPdf(inputFile);
    editor->DeleteImage(1, MakeArray<int32_t>({1}));

    editor->Save(outputFile);
}
} // namespace Facades::Examples::PDF_ContentEditor