property FormFieldCount: Integer; // read only
FormFieldCount returns the number of AcroForm field widget annotations on the
currently active page. Each entry corresponds to one widget annotation (subtype
/Widget with an /FT field type) — text input, check
box, radio button, list box, combo box, push button, or signature field (PDF 1.7 spec
section 12.7).
The value is 0 when Active is False, when
the document is not an AcroForm (FormType = ftNone) or when the page has
no interactive widgets. It is a per-page metric; pages can contain widgets that belong
to the same logical field defined elsewhere in the document tree — PDF allows
one field to have multiple widget placements (e.g. a signature visible on the cover
and the last page).
Use FormFieldInfo[Index] with indices from 0 to
FormFieldCount - 1 to obtain a TPdfFormFieldInfo record:
field type, name, alternate name, flags, option labels, current value, export value,
checked state, and font size. To get a field by hit-testing a page coordinate use
FormFieldAt[X, Y] or FormFieldInfoAt[X, Y] instead.
FormType = ftXfaFull) carry their interactive
structure outside the AcroForm tree; FormFieldCount may still report widgets
generated by XFA, but XFA rendering itself is outside PDFiumVCL’s scope.AnnotationCount overlap because widgets are a
subset of annotations. Use this property when you want only fields.SetFormField invalidates indices.
Re-read FormFieldCount after each mutation.
var I: Integer;
var Info: TPdfFormFieldInfo;
for I := 0 to Pdf1.FormFieldCount - 1 do
begin
Info := Pdf1.FormFieldInfo[I];
Memo1.Lines.Add(Format('%s = %s', [Info.Name, Info.ExportValue]));
end;