{"skill":{"slug":"pdf-form-filler","displayName":"Pdf Form Filler","summary":"Fill PDF forms programmatically with text values and checkboxes. Use when you need to populate fillable PDF forms (government forms, applications, surveys, etc.) with data. Supports setting text fields and checkboxes with proper appearance states for visual rendering.","description":"---\nname: pdf-form-filler\ndescription: Fill PDF forms programmatically with text values and checkboxes. Use when you need to populate fillable PDF forms (government forms, applications, surveys, etc.) with data. Supports setting text fields and checkboxes with proper appearance states for visual rendering.\nversion: 0.2.0\n---\n\n# PDF Form Filler\n\nProgrammatically fill PDF forms with text values and checkboxes. Uses pdfrw to set form field values while preserving appearance streams for proper PDF viewer rendering.\n\n## Quick Start\n\nFill a PDF form with a dictionary of field names and values:\n\n```python\nfrom pdf_form_filler import fill_pdf_form\n\nfill_pdf_form(\n    input_pdf=\"form.pdf\",\n    output_pdf=\"form_filled.pdf\",\n    data={\n        \"Name\": \"John Doe\",\n        \"Email\": \"john@example.com\",\n        \"Herr\": True,  # Checkbox\n        \"Dienstreise\": True,\n    }\n)\n```\n\n## Features\n\n- **Text fields**: Set any text value (names, dates, addresses, etc.)\n- **Checkboxes**: Set boolean values (True for checked, False/None for unchecked)\n- **Appearance states**: Properly sets `/On` and `/Off` states for PDF viewer rendering\n- **Preserves structure**: Doesn't strip form functionality—can be further edited\n- **No dependencies**: Uses pdfrw (lightweight, pure Python)\n\n## How It Works\n\n1. Opens the PDF template\n2. Iterates through form fields\n3. Sets values for matching field names\n4. Handles checkboxes by setting both `/V` (value) and `/AS` (appearance state)\n5. Saves the filled PDF\n\n## Field Name Matching\n\nField names should match exactly as they appear in the PDF form. Common patterns:\n\n- German forms: `Herr`, `Frau`, `Dienstreise`, `Geschäftsnummer LfF`\n- English forms: `Full Name`, `Email`, `Agree`, `Submit`\n- Date fields: `Date`, `DOB`, `Start Date`\n\nTo discover field names in your PDF, use `list_pdf_fields()`:\n\n```python\nfrom pdf_form_filler import list_pdf_fields\n\nfields = list_pdf_fields(\"form.pdf\")\nfor field_name, field_type in fields:\n    print(f\"{field_name}: {field_type}\")\n```\n\nField types:\n- `text`: Text input field\n- `checkbox`: Boolean checkbox\n- `radio`: Radio button\n- `dropdown`: Dropdown select\n- `signature`: Signature field\n\n## Example: Job Application Form\n\n```python\nfill_pdf_form(\n    input_pdf=\"job_application.pdf\",\n    output_pdf=\"job_application_filled.pdf\",\n    data={\n        \"Full Name\": \"Jane Smith\",\n        \"Email\": \"jane.smith@example.com\",\n        \"Phone\": \"555-1234\",\n        \"Position\": \"Software Engineer\",\n        \"Years Experience\": \"5\",\n        \n        # Checkboxes\n        \"Willing to relocate\": True,\n        \"Available immediately\": False,\n        \"Background check consent\": True,\n    }\n)\n```\n\n## Advanced Usage\n\n### Partial fills\n\nOnly fill specific fields, leave others blank:\n\n```python\ndata = {\"Name\": \"Jane Doe\"}  # Only Name is set\nfill_pdf_form(\"form.pdf\", \"form_filled.pdf\", data)\n```\n\n### Dynamic field detection\n\nGet all fields and prompt for values:\n\n```python\nfrom pdf_form_filler import list_pdf_fields\n\nfields = list_pdf_fields(\"form.pdf\")\ndata = {}\nfor field_name, field_type in fields:\n    if field_type == \"text\":\n        data[field_name] = input(f\"Enter {field_name}: \")\n    elif field_type == \"checkbox\":\n        data[field_name] = input(f\"Check {field_name}? (y/n): \").lower() == 'y'\n\nfill_pdf_form(\"form.pdf\", \"form_filled.pdf\", data)\n```\n\n### Batch fills\n\nFill multiple PDFs with the same data:\n\n```python\nimport os\nfrom pdf_form_filler import fill_pdf_form\n\ndata = {\"Name\": \"John Doe\", \"Date\": \"2026-01-24\"}\n\nfor filename in os.listdir(\"forms/\"):\n    if filename.endswith(\".pdf\"):\n        fill_pdf_form(\n            f\"forms/{filename}\",\n            f\"forms_filled/{filename}\",\n            data\n        )\n```\n\n## Troubleshooting\n\n### Checkboxes not showing visually\n\nSome PDF viewers don't render checkboxes immediately. The value is set correctly (`/On` or `/Off`), but appearance isn't regenerated. Try opening in:\n- Adobe Reader (will render automatically)\n- Firefox (has better form support)\n- evince or okular on Linux (usually works)\n\n### Field names not found\n\nUse `list_pdf_fields()` to confirm exact field names. PDF forms can be tricky:\n- Some use unusual names (e.g., `Field_1` instead of descriptive names)\n- Some have nested field structures\n\n### Text appears cut off\n\nSome PDFs have narrow text fields. Either:\n1. Use shorter values\n2. Reduce font size in the PDF template itself\n3. Manual editing after filling\n\n## Bundled Script\n\nSee `scripts/fill_pdf_form.py` for the full implementation using pdfrw.\n","tags":{"latest":"0.2.0"},"stats":{"comments":0,"downloads":5041,"installsAllTime":27,"installsCurrent":27,"stars":4,"versions":2},"createdAt":1769278673244,"updatedAt":1778485848771},"latestVersion":{"version":"0.2.0","createdAt":1769279676336,"changelog":"- Added `pdf_form_filler` module with `__init__.py` and core `fill_pdf_form.py` implementation.\n- Removed legacy script from `scripts/fill_pdf_form.py`.\n- Updated SKILL.md to include version metadata.\n- Improved project packaging and entry points in `setup.py`.","license":null},"metadata":null,"owner":{"handle":"raulsimpetru","userId":"s17cdc4774rfjg07e5xyxyd3m98859ph","displayName":"RaulSimpetru","image":"https://avatars.githubusercontent.com/u/26602941?v=4"},"moderation":null}