Run3 fill pdf form
[COLM'26] SkillLearnBench is the first benchmark for evaluating continual learning methods that automatically generate agent skills.
npx -y skills add cxcscmu/SkillLearnBench --skill run3_fill_pdf_formAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its author says it does
Copied from the file, not written here
Fills a PDF form with provided data. It maps field keys to their respective pages and applies values. It handles multi-line text areas by assigning specific strings to the identified sequential keys. For checkboxes, it uses the precise export values found during inspection. All dates must be formatted as 'xxxx-xx-xx'.
SKILL.md
1.6 KB, as published. Nobody here has run it
import pypdf
def fill_pdf_form(input_pdf_path: str, output_pdf_path: str, data: dict): """ Fills a PDF form. 'data' should be a flat dictionary where keys match the PDF field names. The function automatically identifies the page for each key and updates it. """ reader = pypdf.PdfReader(input_pdf_path) writer = pypdf.PdfWriter() writer.append_pages_from_reader(reader)
# Create a mapping of field keys to page indices
field_to_page = {}
for page_index, page in enumerate(reader.pages):
if "/Annots" in page:
for annot in page["/Annots"]:
obj = annot.get_object()
if "/T" in obj:
field_to_page[obj["/T"]] = page_index
# Group data by page index for update_page_form_field_values
page_updates = {}
for key, value in data.items():
if key in field_to_page:
p_idx = field_to_page[key]
if p_idx not in page_updates:
page_updates[p_idx] = {}
page_updates[p_idx][key] = value
# Apply updates page by page
for p_idx, fields in page_updates.items():
writer.update_page_form_field_values(writer.pages[p_idx], fields)
with open(output_pdf_path, "wb") as output_file:
writer.write(output_file)