Create PDF documents from YAML-configured SVG templates.
- Separation of design and content: Design your layout visually in SVG, while managing content and configuration in YAML.
- Instant templating: Turn any existing SVG into a configurable template with a single command.
pdfbaker is available on PyPI and can be installed using pipx:
pipx install pdfbaker
If you don't have pipx yet, install it first:
sudo apt install pipx
pipx ensurepath
If you are using Windows, GTK needs to be installed: GTK for Windows Runtime Environment Installer
- Choose Install GTK+ libraries
- Tick to setup path (otherwise add the install DLL folder manually)
- Choose your installation location
- Complete the installation
-
For SVG to PDF conversion, CairoSVG is used by default. If you need Inkscape instead, install it:
sudo apt install inkscape
-
For PDF compression, install Ghostscript:
sudo apt install ghostscript
-
If your templates embed particular fonts, they need to be installed. For example for Roboto fonts:
sudo apt install fonts-roboto
The fastest way to get started is with the --create-from
option:
-
Design your document in an SVG editor or convert to SVG.
-
Run pdfbaker with
--create-from
to scaffold a new project and generate your first PDF:pdfbaker --create-from mydesign.svg myproject/myproject.yaml
This will create a directory structure like:
myproject ├── myproject.yaml └── mydesign ├── config.yaml ├── pages │ └── main.yaml └── templates └── main.svg.j2
and produce your PDF in
myproject/dist/mydesign/mydesign.pdf
. -
Edit the template and YAML files to customize your content and variables. This directory structure is just a starting point. Add more documents and customize as needed.
-
For future builds, just run:
pdfbaker myproject/myproject.yaml
to regenerate your PDFs.
- Overview - Start here
- Usage - From the CLI or as a library
- Configuration Reference - All available settings
- Document Variants - Create multiple versions of the same document
- Custom Processing - Provide page content from anywhere
For working examples, see the examples directory:
- minimal - Basic usage
- regular - Standard features
- variants - Document variants
- custom_locations - Custom file/directory locations
- custom_processing - Custom processing with Python
Create all PDFs with:
pdfbaker examples/examples.yaml
All source code is on GitHub.
This project uses uv for dependency management. The
uv.lock
file ensures reproducible builds.
Create and activate the virtual environment:
uv venv
source .venv/bin/activate
Install development dependencies:
uv sync --dev
Run tests:
pytest
View test coverage:
pytest --cov=pdfbaker --cov-report=term-missing
If you want to commit changes, install pre-commit (maybe using uv) and run
pre-commit install
This ensures the same checks run locally as in GitHub CI.