NewMarkupAnnotation
Annotations and hotspot links
Description
Creates a highlight, underline, squiggly or strike-out annotation from an explicit quad list and applies its colour and opacity in one call, returning the 1-based index of the new annotation. Each quad is four points given as X1,Y1 through X4,Y4, the annotation rectangle is taken from the union of the quads, and the function returns 0 when no document is selected or QuadCount and the length of Quads disagree.
Syntax
Delphi
Function TPDFlib.NewMarkupAnnotation(MarkupType: Integer; QuadCount: Integer; Const Quads: Array Of Double; Red, Green, Blue, Opacity: Double): Integer;
Parameters
MarkupType selects the kind of markup: 1 = highlight, 2 = underline, 3 = squiggly, 4 = strike out. QuadCount is the number of quadrilaterals and must be at least 1. Quads holds the quadrilaterals flattened eight doubles at a time, X1, Y1 through X4, Y4 per quad, in the current measurement unit and origin, and must contain at least QuadCount * 8 values. Red, Green and Blue are the markup colour components on a 0..1 scale, and Opacity is the alpha on a 0..1 scale, stored as /CA.
Return values
The 1-based index of the new annotation in the selected page's /Annots array, which is also the index that the annotation style, quad point and attribute setters expect. The result is 0 when no document is open, when QuadCount is below 1, when Quads holds fewer than QuadCount * 8 values, when MarkupType is outside 1..4, or when the underlying annotation could not be added.
Remarks
The annotation is created on the currently selected page and appended last, so a successful call returns the annotation count as it stands afterwards. The initial /Rect is the union of all four corners of every quad, adapted to the active origin so that mirrored axes still yield a rectangle with positive extents; this is why the corner order inside a quad does not matter and why a skewed or rotated quad still gets a box that encloses it. The quad points are then stored verbatim through SetAnnotQuadPoints, one call per quad, and are never re-transformed, so changing the measurement unit or the origin later does not move existing annotations. Since the annotation carries /CA, the document version is raised to 1.4 when it is lower. Opacity is multiplied by 100 for the internal 0..100 style call and is not clamped anywhere, so keep it within 0..1 for a valid alpha.