THotPDF.GetLoadedFormFieldIndexForAnnotation
Maps one loaded page annotation to its terminal AcroForm field and widget ordinal
Declaration
function GetLoadedFormFieldIndexForAnnotation(PageIndex,
AnnotationIndex: Integer; out WidgetIndex: Integer): Integer;
The return value is the zero-based field index and WidgetIndex receives the zero-based ordinal within that field
The method returns -1 and sets WidgetIndex to -1 for invalid coordinates, non-widget annotations, or orphan widgets that are not registered under /AcroForm /Fields
Use the returned object identity mapping after annotation reordering instead of retaining a previous annotation index
See also: AcroForm relationship cache, GetLoadedFormFieldWidgetPageIndex