PDFium Delphi Component Docs

SetFormFieldValue method

Unit: PDFium
function SetFormFieldValue(Index: Integer; const Value: TPdfFormValue;
  out Report: TPdfFormValueWriteReport): Boolean;

These methods write typed AcroForm dictionaries without acquiring or releasing native form focus, sending keystrokes, running validation/calculation JavaScript or changing default values

SetFormFieldValue addresses a zero-based widget field index on the current one-based page; SetFocusedFormFieldValue uses the logical cursor and defaults to nfwReject when no cursor exists

nfwFirstField explicitly targets field index 0 when no cursor exists; it does not skip a read-only, unsupported or otherwise invalid first field

SetFormFieldCursor selects a logical field without invoking FORM_SetFocusedAnnot; it requires no active native focus, and viewer/document pages must match for viewer writes

fvkText writes Text to text fields or editable combo boxes, validating UTF-16 and inherited MaxLen; fvkChoice writes ascending unique zero-based ChoiceIndices using export values rather than display labels

Multiple selections require the field multi-select flag; empty ChoiceIndices clears the value and selection array

fvkCheckBox uses Checked and the addressed widget's on state; fvkRadioButton selects Text as an Opt export string when present, otherwise as the group on-state name, or clears the group when Text is empty and NoToggleToOff permits clearing

Values are stored at the terminal owner, including parent-owned fields shared across pages; all related widgets receive consistent PDF Name appearance states

Any active native form focus rejects the entire transaction before snapshot capture, preserving pending text, selection and focus; callers must explicitly clear/commit focus before retrying

Read-only fields, kind mismatches, unknown/ambiguous radio values, malformed ancestry, signatures, unsupported encrypted profiles, XFA and malformed button export arrays reject with ErrorMessage

Active document/page-object edit transactions must finish first; the method returns Succeeded, Page, FieldIndex and UpdatedWidgets, with zero UpdatedWidgets on failure

The profile permits 262144 UTF-16 text units, 4096 options/shared widgets, ancestry depth 64, 65535 object numbers, 64 MiB source/total object bytes, 8 MiB individual objects, 8388608 work visits and 128 MiB output

A successful bounded dictionary transaction verifies a replacement PDF before publishing it, retains page numbers/view activation/logical cursors and restores LifecycleActionPolicy

Replacement closes native document/page/annotation handles, invalidates searches and selections, and ends incremental-save state; obtain fresh native handles after success

Automatic lifecycle actions are suppressed during replacement; text/choice AP entries are removed only from affected widgets for native missing-appearance regeneration, and global NeedAppearances is cleared

Button Opt arrays use complete terminal Kids order, or one merged owner/widget; strings may be direct or indirect and must be nonempty valid PDF text

With Opt, field V is the selected zero-based control-index PDF Name, whilst each widget AS uses its actual on-state name; shared checkboxes and consistent RadiosInUnison groups synchronise matching widgets

Radio export ambiguity rejects unless RadiosInUnison permits identical export/on-state pairs; count/order mismatches and more than 262144 aggregate decoded export UTF-16 units reject without publication

Direct AcroForm and field dictionaries are normalised in the candidate snapshot before typed writes; unique field-tree ownership supplies missing parent links and equivalent direct parent copies are rebound to their promoted owner

Direct merged widgets and direct Kids widgets require a nonempty unique NM identity of at most 1024 UTF-16 units, one matching page annotation and identical serialised dictionary values except Parent and native-regenerated AP; conflicting source parents, duplicate names and ambiguous matches reject before publication

The field tree and page annotation arrays are rebound to indirect references so the authoritative field value, selected widget and saved document share the same owner; unrelated members and annotation metadata are retained

Normalisation permits 4096 field-tree visits/pages/array members, depth 64, 256 new indirect objects, 1 MiB per promoted direct dictionary, 4 MiB aggregate promoted bytes and 128 MiB of inspected dictionary bytes; full field names permit 4096 UTF-16 units each and 262144 in aggregate

Raw PDF literal-string bytes remain lossless until explicit PDF text decoding; unencrypted candidate trailers carry two 16-byte ID strings, whilst encrypted transactions retain the original first ID

Since v3.249.0, permission-checked AESV3 inputs follow the encrypted AcroForm transaction profile, which also accepts legacy RC4/AESV2 sources, retaining the original security dictionary and credentials