PDFium Delphi Component Docs

TPdf.SetFormFieldValues

Unit: PDFium
function SetFormFieldValues(const Requests: TPdfFormValueRequests;
  out Report: TPdfFormValuesWriteReport): Boolean;

Apply 1..256 requests atomically across explicitly numbered pages; Page is one-based and FieldIndex is the page-local zero-based widget index

All fields share one normalized source snapshot, bounded parser work and sparse output; candidate validation precedes one document replacement

Duplicate terminal field owners reject, including different widgets belonging to a shared field; no request silently overwrites another request

Any invalid request leaves the original native document and values intact; FailedRequest identifies its zero-based request index, or -1 for transaction-level rejection

Active native focus rejects before snapshot capture and preserves pending editor buffers; explicitly commit or clear focus before retrying

Since v3.382.2 an open incremental save session also rejects the write, because publication reloads the document and would otherwise end the session silently; commit or end the session first, call SetFormFieldValues, then begin a new session if further edits should be appended, or save a signed result with SaveSourceBytes

Input limits are 1048576 aggregate UTF-16 text units and 16384 aggregate choice indices, in addition to the existing per-field and document budgets

Successful replacement invalidates native handles, searches and selections; page/view activation and logical cursors are retained, and automatic lifecycle actions are suppressed during replacement

This bounded AcroForm profile does not edit XFA, signature values, unsupported encrypted profiles such as native AESV4 or PDF-MAC sources, or malformed/ambiguous button export arrays

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, while each widget AS uses its actual on-state name; shared checkboxes and consistent RadiosInUnison groups synchronize 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 normalized 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 serialized 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

Normalization 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, while encrypted transactions retain the original first ID

Since v3.343.0, unencrypted signed sources are accepted when their signatures permit the write: certification signatures with DocMDP P=1 reject every change, P>=2 permits value and appearance writes on fields not locked by FieldMDP transforms or signature-field /Lock dictionaries, signature fields and value dictionaries are never writable, and publication appends one revision after the original signed bytes so every recorded ByteRange keeps covering byte-identical segments; since v3.381.4 a DocMDP P=1 recorded in the signed revision refuses the write even when a later revision redefines an indirect parameters object

FieldMDP and signature-field /Lock Fields entries are compared with the fully qualified name of the requested field (ISO 32000-1 12.7.3.2), the partial names of the field and its ancestors joined by periods: an /Exclude list releases only a field whose qualified name is listed exactly, and an /Include list locks a listed field and every field below a listed ancestor; fields that merely share a partial name, such as employer.city and applicant.city, never match each other; since v3.382.4 the locks recorded in every revision a signature covers apply as well, so a later revision that deletes a /Lock dictionary or relaxes a FieldMDP action cannot release a field the signer locked

The instance is reloaded from those published bytes, so write the signed result with SaveSourceBytes; SaveAs and the repair writers re-serialise the document natively and rewrite objects the existing signatures cover, while an incremental save session begun after the write appends after the published bytes (since v3.382.3)

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; signed encrypted sources publish through the same policy since v3.351.0, for RC4, AESV2 and AESV3 alike; native AESV4 and PDF-MAC sources stay unsupported whether signed or not