AddPolygonAnnotation

Annotations and hotspot links

Description

Adds a closed polygon markup annotation (PDF /Subtype /Polygon) to the selected page with the supplied vertex list. The polygon is implicitly closed — readers connect the last vertex back to the first when rendering. The shape can optionally be filled with a solid interior color. Color components and opacity are expressed on a 0–1 scale; Transparency is given on a 0–100 scale (0 = fully opaque, 100 = fully transparent). The library bumps the document version to PDF 1.5 when a Polygon annotation is emitted under a lower minimum-version lock. Defined in ISO 32000-1 §12.5.6.9.

Syntax

int AddPolygonAnnotation(wchar_t * VertexCoords, double BorderWidth, double BorderRed, double BorderGreen, double BorderBlue, int Filled, double FillRed, double FillGreen, double FillBlue, wchar_t * Title, wchar_t * Contents, int Transparency);

Parameters

VertexCoords — Vertex coordinates as a single string of alternating x/y values separated by spaces, commas, semicolons, or tabs. Example: "100 100 200 100 200 200 100 200" defines a square. Requires at least two pairs (four numbers) and an even total count of numbers, otherwise the call returns 0.

BorderWidth — Stroke width of the polygon outline, in current units.

BorderRed, BorderGreen, BorderBlue — RGB components (0–1) of the outline color, written into /C.

Filled — 1 to emit an interior fill color (/IC) for the polygon body, 0 to leave it unfilled.

FillRed, FillGreen, FillBlue — RGB components (0–1) of the interior fill color. Ignored when Filled is 0.

Title — Author name written into the annotation's /T entry. Pass an empty string to skip.

Contents — Body of the popup associated with the annotation. Pass an empty string to skip.

Transparency — Opacity expressed as percentage transparent (0–100). The library converts this to PDF /CA = 1 - Transparency/100 and clamps to range.

Return Value

1 on success, 0 if no document is selected, the vertex string fails to parse, or the annotation could not be created.

Remarks

The annotation /Rect is computed automatically from the vertex extent plus a small padding proportional to the border width so the outline stroke remains inside the annotation bounding box.

Optional advanced fields described by the PDF specification — /BE (border effect, including the cloudy outline style), /IT (intent, including PolygonCloud and PolygonDimension), and /Measure — are not emitted by this entry point. They can be appended after creation by writing them onto the annotation dictionary directly.

To overwrite the outline color, border, contents, or rectangle after creation, use SetAnnotBorderColor, SetAnnotBorderStyle, SetAnnotContents, and SetAnnotRect.