procedure CreateAnnotation(const Annotation: TPdfAnnotation);
| Annotation | TPdfAnnotation. A record describing the annotation to create. Key fields include SubType (annotation type, e.g. highlight, text note, ink), Rect (bounding rectangle in PDF user-space coordinates), Inhalt (the annotation text), and Color (the annotation colour). Fill all relevant fields before passing the record. |
CreateAnnotation fügt der aktuellen Seite eine neue Anmerkung hinzu und verwendet dabei die im TPdfAnnotation record. The annotation is appended to the page's annotation array and becomes immediately accessible via Annotation[AnnotationCount - 1].
The TPdfAnnotation record captures the annotation type (SubType), its position on the page (Rect, in PDF-User-Space-Punkten mit dem Ursprung links unten), den sichtbaren Text oder Tooltip (Inhalt), and the display colour (Color). Setzen Sie jedes Feld, das für den gewählten Untertyp relevant ist, bevor Sie diese Prozedur aufrufen; nicht gesetzte Felder bleiben bei ihren Nullwerten
After creating annotations, call SaveAs um die Änderungen auf der Festplatte zu speichern. Um eine Anmerkung zu entfernen, verwenden Sie DeleteAnnotation with the appropriate 0-based index.
var
Ann: TPdfAnnotation;
begin
Pdf1.PageIndex := 0;
FillChar(Ann, SizeOf(Ann), 0);
Ann.SubType := asHighlight;
Ann.Rect.Left := 72.0;
Ann.Rect.Bottom := 680.0;
Ann.Rect.Right := 300.0;
Ann.Rect.Top := 695.0;
Ann.Contents := 'Key figure — review before sign-off';
Ann.Color := clYellow;
Pdf1.CreateAnnotation(Ann);
Pdf1.SaveAs('output_annotated.pdf');
end;