home / skills / dkyazzentwatwa / chatgpt-skills / form-filler
This skill fills PDF forms programmatically from JSON, CSV, or dictionaries, handling text, checkboxes, dropdowns, and batch operations.
npx playbooks add skill dkyazzentwatwa/chatgpt-skills --skill form-fillerReview the files below or copy the command above to add this skill to your agents.
---
name: form-filler
description: Fill PDF forms programmatically with data from JSON, CSV, or dictionaries. Support for text fields, checkboxes, and dropdowns. Batch filling available.
---
# Form Filler
Fill PDF forms programmatically with structured data.
## Features
- **Field Detection**: Auto-detect form fields
- **Multiple Field Types**: Text, checkbox, dropdown, radio
- **Data Sources**: JSON, CSV, dictionary input
- **Batch Filling**: Fill multiple forms from data file
- **Field Mapping**: Map data keys to field names
- **Flatten Option**: Convert to non-editable PDF
- **Form Info**: List all fields and their types
## Quick Start
```python
from form_filler import FormFiller
filler = FormFiller()
# Load form
filler.load("application_form.pdf")
# Fill fields
filler.fill({
"name": "John Doe",
"email": "[email protected]",
"date": "2024-01-15",
"agree": True # Checkbox
})
# Save filled form
filler.save("filled_form.pdf")
```
## CLI Usage
```bash
# Fill from JSON data
python form_filler.py --input form.pdf --data data.json --output filled.pdf
# List form fields
python form_filler.py --input form.pdf --list-fields
# Fill from CSV (batch)
python form_filler.py --input form.pdf --batch data.csv --output-dir filled/
# Flatten filled form
python form_filler.py --input form.pdf --data data.json --flatten --output filled.pdf
# With field mapping
python form_filler.py --input form.pdf --data data.json --mapping mapping.json -o filled.pdf
```
## API Reference
### FormFiller Class
```python
class FormFiller:
def __init__(self)
# Loading
def load(self, filepath: str) -> 'FormFiller'
# Field Operations
def list_fields(self) -> List[Dict]
def get_field_info(self, field_name: str) -> Dict
def get_field_value(self, field_name: str) -> Any
# Filling
def fill(self, data: Dict) -> 'FormFiller'
def fill_field(self, name: str, value: Any) -> 'FormFiller'
def fill_from_json(self, filepath: str) -> 'FormFiller'
def fill_from_csv_row(self, row: Dict) -> 'FormFiller'
# Field Mapping
def set_mapping(self, mapping: Dict[str, str]) -> 'FormFiller'
# Output
def save(self, filepath: str, flatten: bool = False) -> str
def flatten(self) -> 'FormFiller'
# Batch Processing
def batch_fill(self, input_form: str, data_file: str,
output_dir: str) -> List[str]
```
## Field Types
### Text Fields
```python
filler.fill({
"first_name": "John",
"last_name": "Doe",
"address": "123 Main St"
})
```
### Checkboxes
```python
filler.fill({
"agree_terms": True,
"subscribe": False
})
```
### Radio Buttons
```python
filler.fill({
"gender": "male", # Value of selected option
"payment_method": "credit_card"
})
```
### Dropdowns
```python
filler.fill({
"country": "USA",
"state": "California"
})
```
## Field Discovery
```python
fields = filler.list_fields()
# Returns:
# [
# {"name": "first_name", "type": "text", "required": True},
# {"name": "agree_terms", "type": "checkbox", "value": False},
# {"name": "country", "type": "dropdown", "options": ["USA", "Canada", "UK"]}
# ]
```
## Field Mapping
Map data keys to form field names:
```python
filler.set_mapping({
"fname": "first_name", # data key -> form field
"lname": "last_name",
"addr": "address_line_1"
})
filler.fill({
"fname": "John", # Uses mapping
"lname": "Doe"
})
```
## Batch Filling
### From CSV
```python
# CSV format:
# first_name,last_name,email
# John,Doe,[email protected]
# Jane,Smith,[email protected]
filler.batch_fill(
input_form="application.pdf",
data_file="applicants.csv",
output_dir="filled_forms/"
)
# Creates: filled_forms/application_0.pdf, application_1.pdf, ...
```
### From JSON Array
```python
# JSON format:
# [
# {"first_name": "John", "last_name": "Doe"},
# {"first_name": "Jane", "last_name": "Smith"}
# ]
filler.batch_fill(
input_form="form.pdf",
data_file="data.json",
output_dir="output/"
)
```
## Dependencies
- PyMuPDF>=1.23.0
- pillow>=10.0.0
- pandas>=2.0.0
This skill programmatically fills PDF forms using structured data from JSON, CSV, or in-memory dictionaries. It supports text fields, checkboxes, radio buttons, and dropdowns, with batch processing and optional flattening to produce non-editable PDFs. The API is Python-first and includes field discovery, mapping, and file-based CLI utilities for automation.
Load a PDF form, auto-detect its form fields, and supply a data mapping or data file to populate fields. The skill maps input keys to form field names, applies values to the matching field types (text, checkbox, radio, dropdown), and writes filled outputs. Batch_fill iterates over CSV or JSON arrays to produce one filled PDF per record and can optionally flatten documents to remove editability.
Which field types are supported?
Text fields, checkboxes, radio buttons, and dropdowns are supported, with values provided as strings or booleans as appropriate.
Can I run this in batch from a CSV?
Yes. batch_fill accepts CSV or JSON arrays and writes one filled PDF per record to an output directory.