THotPDF.SetLoadedFormFieldOptions Method

Replace the selected loaded field's option array with flat PDF text strings while coordinating option order, selected indices and the visible top-option identity

Declaration

procedure SetLoadedFormFieldOptions(FieldIndex: Integer; const AOptions: array of AnsiString);

Unit

HPDFDoc

Parameters

NamePurpose
FieldIndexZero-based loaded-field index identifying the field to replace
AOptionsRaw PDF text-string payload bytes for flat options, with identical export and display text; these are not PDF literal syntax or an implicitly UTF-8 array

Ordering and text representation

The replacement stores bare-string options, not export/display pairs, and retains each supplied payload's bytes; prepare valid PDF text strings in the intended encoding before calling

For choice fields, the effective inherited ffSort flag enables stable Windows invariant linguistic sorting of decoded comparison keys; with the flag clear, caller order is retained

Linguistically equal keys keep their input order, and sorting does not normalize stored text or use collation equality to select values; the actual Windows NLS version remains an execution identity, not a universal alphabetical-order guarantee

Choice value and selection

The setter leaves the original /V storage untouched, including presence, object type, literal-versus-hex representation, payload bytes and indirect references; unknown editable-combo custom values remain exact

Valid old effective /I indices first preserve an option's exact decoded export/display pair and its duplicate occurrence; if that occurrence disappears, a surviving exact export may supply the first unused fallback

Present values still determine whether an export is selected, and unmatched value entries never select unrelated rows; final selection indices are ascending positions in the final stored option array

Missing or null /V can retain I-only selection without manufacturing a value; a scalar value with no old effective I does not acquire I solely for replacement

Array-valued V retains a coherent I even if no selection survives; an empty local I masks an inherited stale selection when required

Existing I and TI indices use exact retained PDF number tokens when available; a nonzero fractional part is not rounded into a valid row, while integral spellings with zero fractional suffixes and negative zero remain valid

Visible window and inherited owners

Only an existing explicit effective /TI that resolves to a valid finite integral index within the old option array is identity-mapped; its exact decoded export/display pair and duplicate occurrence follow into the final flat array, or the mapped TI becomes zero if that identity is lost, with no export-only viewport fallback

An absent TI is not manufactured, and an existing null, fractional, out-of-range or otherwise invalid TI retains its original representation and existing appearance fallback; an invalid value is not treated as a valid first-option identity for replacement

The target receives a local option replacement; shared ancestor option arrays and sibling fields are not rewritten

A widget whose TI inherits through the updated field continues to inherit the mapped field TI without receiving an unnecessary local override; a nearer explicit widget-owned TI is planned independently under the same valid-index rule

A widget with its own option array retains that separate option index space and its TI is not remapped through the field's replacement; its existing local I also remains exact

If a changed field I would otherwise alter an own-Opt widget's inherited selection, the widget receives a detached local copy of its old effective I array, or a local null barrier when its old effective I was absent, null or non-array

Affected widget-local I arrays are reconciled in their own selection context, and widget-local V is evaluated independently; no widget V or owned Opt is rewritten

Appearance refresh

This setter does not regenerate appearances; explicitly call EnsureLoadedFieldAppearanceStream after replacement and before saving when refreshed output is required

AutoFormAppearances applies to newly authored fields and does not turn this loaded-field operation into an automatic appearance refresh

This flat replacement API does not create richer option pairs, change authority rules or add complex-font shaping; existing filling and getter APIs do not silently sort a loaded document

Non-choice fields retain their existing flat raw Opt replacement behavior without interpreting the shared flag bit as Sort or introducing choice I or TI planning

Related APIs

GetLoadedFormFieldOptions · GetLoadedFormFieldOption · THotPDF