Replace Text Simple in C++
Contents
[
Hide
]
Use PdfContentEditor for this task. The examples below retain the original C++ code and API Reference steps.
Replace text simple
Set ReplaceAll scope and replace 33 with XXXIII followed by a space.
- Create PdfContentEditor.
- Bind the PDF input with Facade::BindPdf().
- Replace matching text with PdfContentEditor::ReplaceText().
- Save the resulting PDF with PdfContentEditor::
Save().
#include <Aspose.PDF.Cpp/Facades/PdfContentEditor.h>
#include <Aspose.PDF.Cpp/Facades/ReplaceTextStrategy.h>
#include <system/string.h>
namespace Facades::Examples::PDF_ContentEditor
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
void ReplaceTextSimple(String inputFile, String outputFile)
{
auto editor = MakeObject<PdfContentEditor>();
editor->BindPdf(inputFile);
editor->get_ReplaceTextStrategy()->set_ReplaceScope(ReplaceTextStrategy::Scope::ReplaceAll);
editor->ReplaceText(u"33", u"XXXIII ");
editor->Save(outputFile);
}
} // namespace Facades::Examples::PDF_ContentEditor