PDFium Component Docs

AnnotationCount Propriété

Composant: TPdf  ·  Module: PDFium
Number of annotation objects attached to the currently active page.

Syntax

property AnnotationCount: Integer; // read only

Description

AnnotationCount renvoie la longueur de la /Annots array (PDF 1.7 spec section 12.5). All annotation subtypes are counted — text notes, highlights, underlines, free-text, ink, stamps, polygon and polyline shapes, link annotations, popup dialogs, and form widget annotations. Combine the values from every page to obtain the document-wide annotation total.

The property requires Active to be True et lit sur la page indiquée par PageNumber. Lorsque la page ne contient aucune annotation ou que le document n’est pas chargé, la valeur est 0. Use Annotation[Index] with indices from 0 to AnnotationCount - 1 to retrieve a TPdfAnnotation record describing the subtype, bounding rectangle, colour, flag bitmask and contents text of each entry.

Iterating annotations is O(n) but each Annotation[Index] call opens a fresh PDFium handle and decodes Unicode contents on demand; cache the result if you need it multiple times. Mutating a page’s annotations (insertions, deletions) invalidates indices — restart the loop or re-read AnnotationCount after the change.

Remarks

Example

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;

See Also

Annotation, LinkAnnotationCount, FormFieldCount, PageNumber