PDFium Delphi Component Docs

AddPathToAnnotation method

Component: TPdf  ·  Unit: PDFium
Hand the path built with CreatePath to an annotation rather than to the page

Syntax

procedure AddPathToAnnotation(Index: Integer);

IndexInteger. Zero-based index of an ink (anInk) or stamp (anStamp) annotation on the current page. Any other subtype raises EPdfError

Description

Builds on the same pending path as AddPath: call CreatePath, extend it with MoveTo, LineTo, and BezierTo, then commit it here rather than to the page content

The annotation takes ownership, and a path can belong to only one annotation, so the pending path is consumed either way - on success by the annotation, on failure by being destroyed. Either outcome leaves no path pending

PDFium restricts object editing to ink and stamp subtypes, which is why any other subtype is rejected rather than silently doing nothing

Example

Pdf.CreateAnnotation(anInk);
Pdf.CreatePath(100, 100, fmNone, clBlack, $FF, True, clBlue);
Pdf.LineTo(300, 200);
Pdf.AddPathToAnnotation(Pdf.AnnotationCount - 1);

See Also

CreatePath, AddPath, CreateAnnotation, AnnotationObjectCount