PDFium Delphi Component Docs

FormFieldInfoAt property

Component: TPdf  ·  Unit: PDFium
Form field record for the widget located at the given page coordinate

Syntax

property FormFieldInfoAt[X, Y: Single]: TPdfFormFieldInfo; // read only

Description

FormFieldInfoAt performs a hit-test on the currently active page and returns the TPdfFormFieldInfo record describing the widget annotation at (X, Y). Coordinates are in PDF user space, with the origin at the bottom-left corner of the page and units expressed in points (1/72 inch). The record mirrors what FormFieldInfo[Index] returns — field type (fiTextField, fiCheckBox, …), field name, alternate name, flags, option labels, checked state, export value, and font size

When the coordinate does not land inside any widget rectangle, FormFieldInfoAt returns a default-initialized TPdfFormFieldInfo — FieldType = fiUnknown and empty strings throughout. Use HasFormFieldAt[X, Y] for a cheap yes/no probe before retrieving the full record, or simply check the returned FieldType

The lookup is O(n) over the page’s widgets and additionally decodes Unicode field metadata, so it is heavier than HasFormFieldAt. In a mouse-move handler check HasFormFieldAt first; only call FormFieldInfoAt on click or hover-enter. Coordinates from a mouse position go through TPdfView.DeviceToPage first to translate device pixels into page units

Remarks

Example

procedure TForm1.PdfView1Click(Sender: TObject);
var Info: TPdfFormFieldInfo;
  PageX, PageY: Double;
begin
  with PdfView1.ScreenToClient(Mouse.CursorPos) do PdfView1.DeviceToPage(X, Y, PageX, PageY);
  Info := Pdf1.FormFieldInfoAt[PageX, PageY];
  if Info.FieldType <> fiUnknown then
    ShowMessage(Info.Name);
end;

See Also

HasFormFieldAt, FormFieldInfo, FormFieldAt, FormFieldCount