Orchestrate end-to-end reproduction of fillable PDF forms as self-contained Typst packages.
Project description
formalizer
Convert a fillable PDF into a self-contained Typst package that anyone can edit and compile to a near-perfect replica.
Maintained by TtQ.
How it works
- Extract — PyMuPDF reads the PDF and outputs
FIELDS.json(field schema) andpageN.svgbackground images. - Codegen — The orchestrator writes a Typst package with a typed
form()function and a pre-filledexample.typ. - Fill — Edit
example.typ, replace the dummy values with real ones, compile withtypst compile.
<out>/
typst.toml # package manifest
lib.typ # rendering engine
FIELDS.json # extracted field schema
page1.svg # vector page backgrounds
form.typ # generated API wrapper (do not edit)
example.typ # your starting point — edit this
Requirements
- Python ≥ 3.10
- typst CLI (for compiling the output package)
Installation
pip install formalizer
# or
uv add formalizer
Usage
CLI
# Generate a package (name defaults to --out basename)
formalizer --pdf form.pdf --out ./my-form
# Override the package name
formalizer --pdf form.pdf --out ./my-form --name custom-name
# Overwrite an existing output directory
formalizer --pdf form.pdf --out ./my-form -f
After generation the CLI auto-compiles example.typ → example.pdf so you can immediately preview the result.
Python API
from formalizer import generate
# Minimal — name defaults to the out directory basename
generate(pdf="form.pdf", out="./my-form")
# With options
generate(pdf="form.pdf", out="./my-form", name="custom-name", force=True)
Filling the form
Edit the generated example.typ and pass real values to form():
#import "form.typ": form
#form(
first_name: "Jane Smith",
agree_terms: true,
gender: "F",
)
Then compile:
typst compile example.typ filled-form.pdf
Development
# Install in editable mode
pip install -e .
# Run tests
pip install pytest
pytest tests/ -v
Tests that invoke the typst CLI (test_cli, test_codegen_compiles) are skipped automatically if typst is not on PATH.
License
Apache 2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file formalizer-0.2.3.tar.gz.
File metadata
- Download URL: formalizer-0.2.3.tar.gz
- Upload date:
- Size: 351.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0ceceda10dbbe1dd263ad3f4be104cba52b0d53601cfbb33856dbb794fa9f41
|
|
| MD5 |
b8ef44dd35daa1574bc38d6d0b8b8811
|
|
| BLAKE2b-256 |
1a2d55166c04e602130958abad379532a62aab3b267c2dfdf6131cf1346d0c22
|
Provenance
The following attestation bundles were made for formalizer-0.2.3.tar.gz:
Publisher:
publish.yml on nibsbin/formalizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
formalizer-0.2.3.tar.gz -
Subject digest:
f0ceceda10dbbe1dd263ad3f4be104cba52b0d53601cfbb33856dbb794fa9f41 - Sigstore transparency entry: 1248728036
- Sigstore integration time:
-
Permalink:
nibsbin/formalizer@fe670fb041b79620d2a9c8d6ec0adda03db0b09e -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/nibsbin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fe670fb041b79620d2a9c8d6ec0adda03db0b09e -
Trigger Event:
push
-
Statement type:
File details
Details for the file formalizer-0.2.3-py3-none-any.whl.
File metadata
- Download URL: formalizer-0.2.3-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
416671d78076b7c1a1eb1a83e3a497525f99741252b85634d5ac1b49ab212156
|
|
| MD5 |
31b635e812518f26136f7bf25b6abb59
|
|
| BLAKE2b-256 |
9c4fb83742ebab70afb65d2b8032173a5801bddf8339629238b232ae9bf10cf8
|
Provenance
The following attestation bundles were made for formalizer-0.2.3-py3-none-any.whl:
Publisher:
publish.yml on nibsbin/formalizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
formalizer-0.2.3-py3-none-any.whl -
Subject digest:
416671d78076b7c1a1eb1a83e3a497525f99741252b85634d5ac1b49ab212156 - Sigstore transparency entry: 1248728044
- Sigstore integration time:
-
Permalink:
nibsbin/formalizer@fe670fb041b79620d2a9c8d6ec0adda03db0b09e -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/nibsbin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fe670fb041b79620d2a9c8d6ec0adda03db0b09e -
Trigger Event:
push
-
Statement type: