procedure CreateAnnotation(const Annotation: TPdfAnnotation);
| Annotation | TPdfAnnotation。描述所要建立註解的記錄。主要欄位包含 SubType(註解類型,例如高亮度、文字註記、筆跡)、Rect(PDF 使用者空間座標中的週框)、Contents(註解文字)與 Color(註解顏色)。傳遞記錄前請填入所有相關欄位 |
CreateAnnotation 會使用 TPdfAnnotation 記錄中提供的屬性,將新的註解新增至目前頁面。該註解會附加至頁面的註解陣列,並可立即透過 Annotation[AnnotationCount - 1] 存取
TPdfAnnotation 記錄會擷取註解類型(SubType)、其在頁面上的位置(Rect,以原點在左下角的 PDF 使用者空間點表示)、可見文字或工具提示(Contents)與顯示顏色(Color)。呼叫此程序前,請設定與所選子類型相關的每個欄位;未設定的欄位會保留其零值
建立註解後,請呼叫 SaveAs 將變更保存至磁碟。若要移除註解,請使用 DeleteAnnotation 並傳入適當的從 0 起始索引
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;