|
|
hai 2 meses | |
|---|---|---|
| .. | ||
| cases | hai 2 meses | |
| README.md | hai 2 meses | |
| field_values.template.json | hai 2 meses | |
Distilled from reference examples m03 (Italian visa AcroForm fill). FILL route — unlike the other five CREATE / REFORMAT templates, this one has no HTML/CSS skeleton, only a
field_values.jsonschema
- a procedural checklist.
FILL route (separate from CREATE / REFORMAT). Steps:
fill probe target.pdf — confirm acroform=true. Otherwise switch to the overlay
path.fill inspect target.pdf inspect.json — extract qname / type / on_value /
radio_choices / box / page_no.DD-MM-YYYY, name -> uppercase pinyin, phone
normalisation, etc. If the task is an Italian / Schengen visa form filled from Chinese employment
certificate + itinerary, load the progressive case first:
../../../docs/italy-schengen-visa-acroform-case.md and copy-edit
cases/italy-schengen-visa-example/field_values.case.json.page_no for a second check (do
not match by widget short name only — same-name widgets collide).Why AcroForm instead of visual overlay: government PDFs require machine-readable / searchable field
values; the bulk-write API keyed by short name writes through the same parent name to multiple
children, polluting unrelated fields (in m03 the literal "Other" appears across several questions
— that was the biggest pitfall). The qname emitted by fill inspect is a fully qualified name
(with parent path), so identical short names under different parents resolve to different qnames and
disambiguate themselves.
Other
appears in marital status + travel purpose; Valid until appears in passport expiry + residence
permit expiry). The qname from inspect already includes the parent prefix, so it
self-disambiguates. If two fields share both short name and parent (rare), page_no is the second
guard — apply rejects writes whose page_no does not match the inspect record.DD-MM-YYYY (EU visas) / YYYY-MM-DD (US tax) — check the form first.maxlen; if the value is longer, truncate to maxlen-1 + "..." and warn
the user.on_value varies (/Yes / /No / /X / /1 / /2 / /Off) — always look up
the literal in the inspect output's on_value field. Never write "true" or "checked"
literals.\n (do not use ; or ,).missing_required so the user can do them by
hand.See field_values.template.json (action template schema) + the
procedure below.
The template's writes array carries metadata per record (source / transform / maxlen / validation
/ ...) so the LLM can self-track. fill apply reads only qname / page_no / set_to and ignores
the rest.
Procedure (run in order; every command from the skill root):
SKILL=packages/local-runtime/assets/skills/pdf
# 1. Probe.
bash $SKILL/scripts/make.sh fill probe target.pdf
# Expect acroform=true. Otherwise switch to the overlay path.
# 2. Inspect field metadata.
bash $SKILL/scripts/make.sh fill inspect target.pdf /tmp/fill/inspect.json
# Read: qname total / type / on_value / radio_choices[].set_to / page_no.
# 3. Build field_values.json from inspect.json.
cp $SKILL/templates/form-fill-acroform/field_values.template.json /tmp/fill/field_values.json
# Populate with source data + transform rules
# (each entry must carry qname / page_no / type / set_to / source).
# 4. Same short-name disambiguation: the qname from inspect already includes
# the parent path, which is enough for the common case.
python3 -c "
import json
fields = json.load(open('/tmp/fill/field_values.json'))['writes']
keys = [(f['page_no'], f['qname']) for f in fields]
assert len(keys) == len(set(keys)), 'Warning: duplicate (page_no, qname) — same-parent collision unresolved'
"
# 5. Visual-only fields: list under missing_required (do not feed apply).
# 6. Extract the apply payload — apply only consumes the three core fields.
jq '.writes | map({qname, page_no, set_to})' \
/tmp/fill/field_values.json > /tmp/fill/values.json
# 7. Apply.
bash $SKILL/scripts/make.sh fill apply target.pdf /tmp/fill/values.json /tmp/fill/filled.pdf
# apply validates: unknown qname / page_no mismatch / illegal checkbox / radio /
# choice values are rejected with an error and a non-zero exit code.
# 8. Visual verification.
bash $SKILL/scripts/make.sh fill rasterize /tmp/fill/filled.pdf /tmp/fill/preview/
# Open preview/page_*.png and spot-check text / checkbox marks.
# 9. Emit USER-FINAL-SUMMARY.md (alongside the PDF).
# Include: filled count / missing SHOWSTOPPERs / visual-only manual items / usage notes.
Other appears in both Q9
(marital status) and Q21 (travel purpose); Valid until appears in both Q15 (passport) and Q18
(residence permit). The qname from fill inspect already prefixes the parent path so most
cases are auto-disambiguated; apply adds a page_no second check, so a write to the wrong page
is rejected./1 /2 /3, others /Yes /No /X, others a
custom literal. Copy on_value / off_value directly from the inspect output, never "true"
/ "checked".\n only when /Ff has bit 13 set. Without it the literal \n is rendered.fill apply defaults
/NeedAppearances=true, which most viewers honor.YYYY-MM-DD, target DD-MM-YYYY (EU) or MM/DD/YYYY (US).
Always transform — never paste raw.maxlen-1 + "...", and warn.+86-138-0000-1234
with four zeros, @email.com fake domain, HTL-001 template booking number). Detect and leave
blank, then report to the user./T or /FT. The script cannot fill them. Record their
coordinates and add them to missing_required.Required:
fill inspect).Optional:
field_values.json as a template).Structural invariants:
_meta block: form_id / widget_total / source_pdf / comments (justify hard rules).writes[] entry must carry (qname, page_no, type, set_to, source, validation).missing_required[] must enumerate every required-but-not-filled field + reason.USER-FINAL-SUMMARY.md is a required deliverable (not optional).apply; if apply fails, cross-reference
inspect.json to find the bad qname.Swappable:
Re-derive per form; do not template the mapping. Every government or institutional form has its
own qname conventions, language quirks, required-field rules, and on_state literals. Re-run
fill inspect and rebuild field_values.json from the resulting roster every time — never paste a
mapping table from a previous form unless it is provably the same form (same form_id in _meta).
Boundary with CREATE / REFORMAT: