Welcome to PyPDFForm⚓︎
PyPDFForm is a Python library and command line tool for working with PDF forms. It provides Python APIs and CLI commands for creating, inspecting, updating, and filling forms, plus common PDF utilities.
With PyPDFForm, you can:
- Create PDF forms, form fields, and raw elements.
- Inspect form fields, metadata, and values.
- Update field styling, behavior, and scripts.
- Fill PDF forms.
- Extract pages and merge PDFs.
The goal is to make PDF form work straightforward, whether you are handling one document or building a larger workflow.
Quickstart⚓︎
Here's a quick look at PyPDFForm as a Python library:
from pprint import pprint
from PyPDFForm import BlankPage, Fields, PdfWrapper, RawElements
# Create a blank PDF
pdf = PdfWrapper(BlankPage())
# Draw labeling texts
pdf.draw(
[
RawElements.RawText("My Textfield:", 1, 100, 600),
RawElements.RawText("My Checkbox:", 1, 100, 550),
]
)
# Create text and checkbox fields
pdf.bulk_create_fields(
[
Fields.TextField("my_textfield", 1, 180, 596, height=16),
Fields.CheckBoxField("my_checkbox", 1, 180, 546, size=16),
]
)
# Inspect the fields via JSON schema
pprint(pdf.schema)
# Change the field styles
pdf.widgets["my_textfield"].font_color = (1, 0, 0)
pdf.widgets["my_textfield"].alignment = 1
# Fill the newly created form
pdf.fill(
{
"my_textfield": "this is a text field",
"my_checkbox": True,
}
)
# Save the new form
pdf.write("output.pdf")
The same workflow can be run from the CLI:
What's next?⚓︎
- Read the User Guide for detailed usage guides.
- Read the Developer Guide if you want to contribute.
- Submit GitHub Issues to report bugs.
- Star to support this project.