procedure CreateAnnotation(const Annotation: TPdfAnnotation);
| Annotation | TPdfAnnotation. 생성할 annotation을 설명하는 record입니다. 핵심 field에는 SubType(annotation type, 예: highlight, text note, ink), Rect(PDF user-space coordinate의 bounding rectangle), Contents(annotation text), Color(annotation color)가 있습니다. record를 넘기기 전에 관련 field를 모두 채우세요 |
CreateAnnotation는 TPdfAnnotation record에 담긴 property를 사용해 현재 page에 새 annotation을 추가합니다. annotation은 page의 annotation array 끝에 붙고, 곧바로 Annotation[AnnotationCount - 1]로 접근할 수 있습니다
TPdfAnnotation record는 annotation type(SubType), page상의 위치(Rect, 왼쪽 아래 원점의 PDF user-space point), 보이는 text 또는 tooltip(Contents), 표시 색상(Color)을 담습니다. 선택한 subtype과 관련된 field를 모두 설정한 뒤 이 procedure를 호출하세요; 설정하지 않은 field는 zero value로 남습니다
annotation을 만든 뒤에는 SaveAs를 호출해 변경 내용을 디스크에 저장하세요. annotation을 제거하려면 적절한 0 기반 index와 함께 DeleteAnnotation을 사용하세요
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;