Add Polygon Annotation in C++
Contents
[
Hide
]
Use PdfContentEditor for this task. The examples below retain the original C++ code and API Reference steps.
Add polygon annotation
Create a page 1 polygon annotation using the LineInfo vertex array.
- Set the polygon vertices and border through LineInfo.
- Create PdfContentEditor.
- Bind the PDF input with Facade::BindPdf().
- Create the polygon annotation with PdfContentEditor::CreatePolygon().
- Save the resulting PDF with PdfContentEditor::
Save().
#include <Aspose.PDF.Cpp/Facades/LineInfo.h>
#include <Aspose.PDF.Cpp/Facades/PdfContentEditor.h>
#include <drawing/rectangle.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;
using Rectangle = System::Drawing::Rectangle;
void AddPolygonAnnotation(String inputFile, String outputFile)
{
auto editor = MakeObject<PdfContentEditor>();
editor->BindPdf(inputFile);
auto lineInfo = MakeObject<LineInfo>();
lineInfo->set_BorderStyle(0);
lineInfo->set_VerticeCoordinate(MakeArray<float>({100, 200, 150, 260, 220, 220, 200, 160}));
editor->CreatePolygon(lineInfo, 1, Rectangle(90, 150, 150, 120), u"This is polygon annotation");
editor->Save(outputFile);
}
} // namespace Facades::Examples::PDF_ContentEditor