Expand description
Single reliable AcroForm value writeback (D-chain).
apply_field_value is the one SDK-level operation for setting a form
value on a lopdf::Document. It owns the complete chain the PDF spec and
the reference implementations (pdfium, mupdf, pdf.js) require:
/V— text values via the ASCII-literal-else-UTF-16BE+BOM policy (ISO 32000-1 §7.9.2.2); button values as byte-exact/Nameobjects (§12.7.4.2.3)./AS— kept consistent with/Von every widget of a button field: a widget’s/ASbecomes the on-state iff that name is a key of the widget’s own/AP /Nsub-dictionary, else/Off(the mupdfset_check_grprule)./AP— text and choice widgets get a regenerated/AP /NForm XObject (/Tx BMC … EMC, WinAnsi-encoded show text, AFM-measured positioning, comb/multiline/quadding support) so the fill is visible in every viewer without/NeedAppearancesprocessing./NeedAppearances— settrueonly as a fallback when appearance generation is not trustworthy (value not WinAnsi-representable); the stale/AP /Nis removed in that case so no viewer shows the old value. PDF 2.0 deprecatesNeedAppearances, so the primary path never sets it.
Field lookup accepts fully-qualified names (parent.kid) and recurses
through /Kids, unlike the historical top-level-only paths. Read-only
fields (/Ff bit 1, inherited) are rejected — note this is stricter than
pdfium/mupdf, which only enforce read-only in their UI layers; an SDK has
no UI layer, so set-time enforcement is the only place the contract can
live.
Structs§
- Write
Outcome - What
apply_field_valuedid, for callers that report or log.
Enums§
- Write
Value - The value to write, by field family.
- Writeback
Error - Errors surfaced by
apply_field_value.
Functions§
- apply_
choice_ multi - Set multiple selected values on a multi-select list box (
/Ffbit 22). - apply_
field_ value - Set a form field value, updating
/V,/AS,/APand (only as an encoding fallback)/NeedAppearances. See the module docs for the chain. - regenerate_
appearances - Regenerate
/AP /Nfor every filled text/choice field in the document.