Forms like ACORD insurance applications, IRS forms, and government PDFs almost never use readable field names. Internally, a field might be named Form_CommlPolicy_PolicyNumber_A instead of a friendly label like Policy Number. You cannot fill a field until you know its exact name, so the first step is always to list the names the PDF actually uses.
Step 1: List every field name
from pypdf import PdfReader
reader = PdfReader("acord_form.pdf")
fields = reader.get_fields()
for name, field in (fields or {}).items():
print(name, "->", field.get("/FT"), field.get("/_States_"))get_fields() returns a dictionary keyed by the fully qualified field name. /FT is the field type: /Tx for text, /Btn for checkboxes and radio buttons, and /Ch for dropdowns. For checkboxes and radios, /_States_ lists the accepted values (for example, /Off and /Yes), which you need in the next step.
Step 2: Fill each field by its exact name
from pypdf import PdfReader, PdfWriter
reader = PdfReader("acord_form.pdf")
writer = PdfWriter()
writer.append(reader)
data = {
"Form_CommlPolicy_PolicyNumber_A": "CPP-000123",
"NamedInsured_FullName_A": "Acme Manufacturing LLC",
"Policy_NewRenewal_NewBusinessIndicator_A": "/Yes",
}
for page in writer.pages:
writer.update_page_form_field_values(page, data, auto_regenerate=False)
with open("acord_form_filled.pdf", "wb") as f:
writer.write(f)The keys must match the names from Step 1 character for character. A key that does not exist is silently ignored, which is the usual reason a field comes back blank when you were sure you set it.
Two things that trip people up
Checkboxes and radio buttons do not accept true or Yes by default. They accept one of the export states you saw in /_States_, so pass /Yes (or whatever value the form defines), not a boolean.
Many older ACORD and LiveCycle forms are XFA forms rather than standard AcroForms. get_fields() will not expose their fields the same way, and pypdf cannot fill the dynamic XFA layer. If your field list comes back empty on a form that clearly has fillable boxes, that is the likely cause: flatten the form to a standard AcroForm first, then fill it.
If you would rather not write Python, command line tools like qpdf and pdftk (through its dump_data_fields operation) can print the same field list for a quick look before you automate.
Back to All Questions