| name | fill-sc100-small-claims-form |
| description | Use this skill to fill in the California SC-100 Small Claims Court PDF form with case data and save the filled PDF. Handles text fields, checkboxes, and radio buttons using pypdf. Run the inspection skill first to confirm field names, then use this skill to write the filled PDF to /root/sc100-filled.pdf. |
Fill SC-100 Small Claims Court Form
Step 1: Inspect the form fields first
import pypdf
reader = pypdf.PdfReader("/root/sc100-blank.pdf")
fields = reader.get_fields()
if not fields:
print("No fields found!")
else:
for name, obj in fields.items():
ft = obj.get("/FT", "?")
val = obj.get("/V", "")
ap = obj.get("/AP", {})
on_states = []
if ft == "/Btn" and ap:
n = ap.get("/N", {})
if hasattr(n, 'keys'):
on_states = [k for k in n.keys() if k != "/Off"]
print(f"{repr(name):60s} type={ft} val={repr(val)} on_states={on_states}")
python3 /root/inspect_sc100.py
Step 2: Fill the form
import pypdf
from pypdf.generic import (
NameObject, StringObject, BooleanObject, ArrayObject,
DictionaryObject, NumberObject
)
import copy
def fill_pdf(input_path, output_path, field_values, checkbox_values):
reader = pypdf.PdfReader(input_path)
writer = pypdf.PdfWriter()
writer.append(reader)
for page in writer.pages:
writer.update_page_form_field_values(page, field_values)
if checkbox_values:
for page in writer.pages:
if "/Annots" in page:
for annot_ref in page["/Annots"]:
annot = annot_ref.get_object()
if annot.get("/Subtype") == "/Widget":
ft = annot.get("/FT", "")
t = annot.get("/T", "")
parent = annot.get("/Parent", None)
field_name = str(t)
if parent:
parent_obj = parent.get_object() if hasattr(parent, 'get_object') else parent
parent_t = parent_obj.get("/T", "")
parent_t:
field_name = (parent_t)
ft == field_name checkbox_values:
export_val = checkbox_values[field_name]
annot_obj = annot
annot_obj.update({
NameObject(): NameObject(export_val),
NameObject(): NameObject(export_val),
})
(output_path, ) f:
writer.write(f)
()
text_fields = {
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
}
checkbox_fields = {
: ,
: ,
}
fill_pdf(
,
,
text_fields,
checkbox_fields
)
python3 /root/fill_sc100.py
Step 3: Verify the output
import pypdf
reader = pypdf.PdfReader("/root/sc100-filled.pdf")
fields = reader.get_fields()
for name, obj in fields.items():
val = obj.get("/V", "")
if val and val not in ("", "/Off"):
print(f"{name}: {repr(val)}")
python3 /root/verify_sc100.py
Step 4: If field names differ, use this robust filler
If the above doesn't work due to field name mismatches, use this approach after inspecting:
import pypdf
from pypdf.generic import NameObject, StringObject
def get_all_widget_annotations(writer):
"""Get all widget annotations with their field names."""
widgets = []
for page_num, page in enumerate(writer.pages):
if "/Annots" in page:
for annot_ref in page["/Annots"]:
annot = annot_ref.get_object()
if annot.get("/Subtype") == "/Widget":
t_parts = []
obj = annot
while obj:
t = obj.get("/T")
if t:
t_parts.insert(0, str(t))
parent_ref = obj.get("/Parent")
if parent_ref:
obj = parent_ref.get_object()
else:
break
full_name = ".".join(t_parts)
ft = annot.get("/FT", "")
if not ft:
par = annot.get("/Parent")
if par:
ft = par.get_object().get("/FT", "")
widgets.append((full_name, ft, annot, annot_ref, page_num))
widgets
reader = pypdf.PdfReader()
writer = pypdf.PdfWriter()
writer.append(reader)
widgets = get_all_widget_annotations(writer)
()
name, ft, annot, ref, pg widgets:
val = annot.get(, )
ap = annot.get(, {})
on_states = []
ft == ap:
n = ap.get(, {})
(n, ):
on_states = [k k n.keys() k != ]
()
python3 /root/fill_sc100_robust.py
Step 5: Final fill using exact field names from inspection
After confirming exact field names, update and run:
import pypdf
from pypdf.generic import NameObject, StringObject
reader = pypdf.PdfReader("/root/sc100-blank.pdf")
writer = pypdf.PdfWriter()
writer.append(reader)
text_data = {}
for page in writer.pages:
if text_data:
writer.update_page_form_field_values(page, text_data)
for page in writer.pages:
if "/Annots" not in page:
continue
for annot_ref in page["/Annots"]:
annot = annot_ref.get_object()
if annot.get("/Subtype") != "/Widget":
continue
t = annot.get("/T", "")
parent = annot.get("/Parent")
if parent:
p_obj = parent.get_object()
pt = p_obj.get("/T", "")
if pt:
t = pt
field_name = str(t)
ft = annot.get("/FT", "")
if not ft and parent:
ft = parent.get_object().get("/FT", "")
checkbox_map = {}
ft == field_name checkbox_map:
export = checkbox_map[field_name]
annot.update({
NameObject(): NameObject(export),
NameObject(): NameObject(export),
})
(, ) f:
writer.write(f)
()