Add Text Annotations in C++
Contents
[
Hide
]
Use PdfContentEditor for this task. The examples below retain the original C++ code and API Reference steps.
Add text annotation
Create an open text annotation titled Text Annotation on page 1.
- Create PdfContentEditor.
- Bind the PDF input with Facade::BindPdf().
- Create the text annotation with PdfContentEditor::CreateText().
- Save the resulting PDF with PdfContentEditor::
Save().
#include <Aspose.PDF.Cpp/Facades/PdfContentEditor.h>
#include <drawing/rectangle.h>
#include <system/string.h>
namespace Facades::Examples::PDF_ContentEditor
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
using Rectangle = System::Drawing::Rectangle;
void AddTextAnnotation(String inputFile, String outputFile)
{
auto editor = MakeObject<PdfContentEditor>();
editor->BindPdf(inputFile);
editor->CreateText(Rectangle(100, 400, 50, 50), u"Text Annotation", u"This is a text annotation", true, u"Insert",
1);
editor->Save(outputFile);
}
} // namespace Facades::Examples::PDF_ContentEditor