Replace Images in PDF in C++
Contents
[
Hide
]
Use PdfContentEditor for this task. The examples below retain the original C++ code and API Reference steps.
Replace image
Replace image index 1 on page 1 with imageFile.
- Create PdfContentEditor.
- Bind the PDF input with Facade::BindPdf().
- Replace the selected image with PdfContentEditor::ReplaceImage().
- 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 ReplaceImage(String inputFile, String imageFile, String outputFile)
{
auto editor = MakeObject<PdfContentEditor>();
editor->BindPdf(inputFile);
editor->ReplaceImage(1, 1, imageFile);
editor->Save(outputFile);
}
} // namespace Facades::Examples::PDF_ContentEditor