THotPDF.SetFormFieldValue Method
Sets the value of a field in a loaded AcroForm. Text and choice fields also receive a new appearance stream showing the value, so every viewer and printer shows the new text; check boxes and radio buttons switch their appearance state to the new value. Save the document with SaveLoadedDocument or an incremental update afterwards
For loaded multiline text fields, the generated appearance preserves explicit empty paragraphs and their line spacing whilst wrapping non-empty paragraphs at whole-word boundaries. CR, LF and CRLF separators are supported. A single terminal separator ends the preceding paragraph; two terminal separators retain one trailing empty paragraph. An empty whole value produces an empty appearance
Declaration
procedure SetFormFieldValue(FieldIndex: Integer; const Value: AnsiString); overload;
procedure SetFormFieldValue(const FieldName, Value: AnsiString); overload;
Unit
HPDFDoc
Parameters
| Name | Purpose |
|---|---|
FieldIndex | Index of the field, from 0 to GetFormFieldCount - 1 |
FieldName | Fully qualified field name, as returned by GetFormFieldName |
Value | New value; for check boxes and radio buttons the export value of the state to select, or Off |
Return value
This member returns no value
Usage notes
- The regenerated appearance uses the field's default appearance string (
/DA) and the font it names in the AcroForm default resources - Password fields are drawn with one asterisk per character; the value itself is still stored in the field
- The previous appearance stream is no longer referenced but remains in a fully rewritten file; use
ApplyUnreachableObjectPolicyorSanitiseLoadedDocumentwhen the old value must not stay in the file