PDF Form Fill
Writes into fields that are already there. Nothing is laid out here.
Procedure
- Dump the field list first. A form with no AcroForm fields is a scan, and it needs an entirely different approach than the one below.
- Map each field name to the value it should carry. Field names are frequently meaningless, so match them by reading the rendered labels beside them.
- Write the values, then read the document back and compare against the map. A silent write into a read-only field looks exactly like success.
- Checkboxes and radio groups take export values, not "true". Read the allowed values off the field before setting one.
- Flatten only after the read-back check passes. Flattening is irreversible.
- Save as a new file. Never overwrite the blank.
Checks
- Every mapped field appears in the read-back with the value it was given.
- No field was left with a stale default from the blank.
- The flattened copy renders identically to the filled one before flattening.