PDFiumVCL Docs

AnnotationCount property

Dieser API-Eintrag behält Bezeichner, Signaturen, Codeblöcke und PDF-Begriffe in ihrer Originalform.
Component: TPdf  ·  Unit: PDFium
Number of annotation objects attached to the currently active page.

Syntax

property AnnotationCount: Integer; // read only

Description

AnnotationCount returns the length of the current page’s /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 and reads from the page indicated by PageNumber. When the page has no annotations or the document is not loaded, the value is 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