agentsclimarketplace

Pdf form filling

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-claude-opus-4-6/court-form-filling/pdf-form-filling

Fill PDF form fields using pypdf library in Python, including text fields and checkboxes.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill pdf-form-filling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.7 KB, 465 tokens by cl100k_base, as published. Nobody here has run it

PDF Form Filling with pypdf

When to Use

When you need to programmatically fill in PDF forms (AcroForms) with text values and checkbox selections.

Setup

pip install pypdf

Key Concepts

Reading Form Fields

import pypdf
reader = pypdf.PdfReader('form.pdf')
fields = reader.get_fields()
for name, field in fields.items():
    print(f"{name} | type={field.get('/FT')} | states={field.get('/_States_', [])}")
  • /FT = /Tx → text field
  • /FT = /Btn → checkbox/button
  • /_States_ shows valid values for checkboxes (e.g., ['/1', '/Off'])

Filling the Form

reader = pypdf.PdfReader('blank.pdf')
writer = pypdf.PdfWriter()
writer.append(reader)

# Build field data dict - keys are FULL field paths
field_data = {
    "Form[0].Page1[0].TextField[0]": "value",
}

# For checkboxes, use the "on" state value from _States_ (e.g., '/1', '/2')
field_data["Form[0].Checkbox[0]"] = "/1"  # checked
# Use '/Off' for unchecked (usually default)

# Update fields on specific pages
writer.update_page_form_field_values(writer.pages[page_idx], field_data)

with open('filled.pdf', 'wb') as f:
    writer.write(f)

Important Notes

  • Field names are hierarchical paths like SC-100[0].Page2[0].List1[0].Item1[0].PlaintiffName1[0]
  • update_page_form_field_values only updates fields present on the specified page
  • For radio-button-style checkboxes (Yes/No pairs), each option has its own field with different "on" states (/1 for first, /2 for second)
  • Always use the full field path as the key
  • Auto-formatting may not work; set /NeedAppearances if text doesn't display

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.