Delete All Images from PDF in C++

Contents
[ ]

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

Delete images

Call DeleteImage() without arguments to remove images from the bound PDF.

  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/string.h>

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

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

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