property AnnotationCount: Integer; // read only
AnnotationCount는 현재 page의 /Annots array 길이를 반환합니다(PDF 1.7 spec 12.5절). text note, highlight, underline, free-text, ink, stamp, polygon, polyline shape, link annotation, popup dialog, form widget annotation 등 모든 annotation subtype이 카운트됩니다. 모든 page의 값을 합치면 문서 전체 annotation 총계를 얻을 수 있습니다
이 속성은 Active가 True여야 하며 PageNumber가 가리키는 page에서 읽습니다. page에 annotation이 없거나 문서가 로드되지 않았으면 값은 0입니다. 각 entry의 subtype, bounding rectangle, colour, flag bitmask, contents text를 담은 TPdfAnnotation record를 얻으려면 0부터 AnnotationCount - 1까지의 인덱스로 Annotation[Index]를 사용하세요
annotation을 순회하는 비용은 O(n)이지만 각 Annotation[Index] 호출은 새 PDFium handle을 열고 필요할 때 Unicode contents를 디코딩합니다. 여러 번 쓸 값이면 결과를 캐시하세요. page annotation을 편집(insert, delete)하면 인덱스가 무효화되므로, 편집 후에는 루프를 다시 시작하거나 AnnotationCount를 다시 읽으세요
FormFieldCount를 사용하세요LinkAnnotationCount[PageNumber]를 사용하세요
이 속성은 모든 page에서 subtype /Link만 직접 필터링합니다
var I: Integer;
var A: TPdfAnnotation;
for I := 0 to Pdf1.AnnotationCount - 1 do
begin
A := Pdf1.Annotation[I];
Memo1.Lines.Add(Format('%d: subtype=%d text=%s',
[I, Ord(A.Subtype), A.ContentsText]));
end;