PDF Form Engine is a cross-platform command-line tool that converts existing PDFs into fillable AcroForm templates and generates filled PDFs using structured JSON data.
It is designed to be used as:
- A native engine behind desktop form editors (e.g. Flutter, Electron)
- A backend utility for generating PDFs from user input
- A standalone PDF form processing tool
The tool uses PyMuPDF (MuPDF) for reliable and standards-compliant PDF manipulation.
- Create fillable PDF forms (AcroForms) from existing PDFs
- Define form fields using a JSON schema
- Support for text fields, checkboxes, radio buttons, and dropdowns
- Fill PDF forms programmatically using JSON input
- Optional flattening of filled PDFs
- Works without Adobe Acrobat
- Cross-platform (Linux, macOS, Windows)
- Can be distributed as a single standalone binary
- Python 3.8+ (not required when using the compiled binary)
- PyMuPDF
- Click
pip install -e .python -m pdf_form_engine --helpBuild the binary:
pyinstaller \
--onefile \
--name pdf-form-engine \
--collect-all pymupdf \
pdf_form_engine/__main__.pyThe binary will be available at:
dist/pdf-form-enginepdf-form-engine apply \
--input original.pdf \
--schema schema.json \
--output fillable.pdfpdf-form-engine fill \
--input fillable.pdf \
--data data.json \
--output filled.pdfpdf-form-engine fill \
--input fillable.pdf \
--data data.json \
--output final.pdf \
--flattenFlattening removes form fields and produces a final, non-editable PDF.
Form fields are defined using a JSON schema.
Example:
{
"fields": [
{
"name": "customer_name",
"type": "text",
"page": 0,
"x": 120,
"y": 540,
"width": 220,
"height": 22,
"required": true
},
{
"name": "agree_terms",
"type": "checkbox",
"page": 1,
"x": 90,
"y": 410,
"width": 15,
"height": 15
}
]
}Notes:
- Page numbers are 0-based
- Coordinates are in PDF points
- Field names must be unique
{
"customer_name": "Ali Yar Khan",
"agree_terms": true
}Typical Use Cases
- PDF form builders and editors
- Contract and agreement generation
- Invoice and bill generation
- Government and compliance forms
- Desktop applications requiring local PDF processing
- Backend PDF automation pipelines
- Does not support XFA forms
- Scanned PDFs require OCR before processing
- Appearance styling is minimal by default
- OCR support for scanned PDFs
- Field appearance customization
- Auto field detection
- Schema validation
- Logging and error reporting
MIT License
- PyMuPDF (MuPDF)
- MuPDF Project