SVG Jinja templates + YAML config = PDF documents
Project description
pdfbaker
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.
Installation
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
Windows Requirements
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
Optional Dependencies
-
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
Quickstart: Create templated PDF from an SVG
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-fromto 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.yamlto regenerate your PDFs.
Documentation
- 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
Examples
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
Development
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
Tests
Run tests:
pytest
View test coverage:
pytest --cov=pdfbaker --cov-report=term-missing
Pre-commit hook
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.
Project details
Release history Release notifications | RSS feed
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 pdfbaker-0.11.1.tar.gz.
File metadata
- Download URL: pdfbaker-0.11.1.tar.gz
- Upload date:
- Size: 168.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b488ac48fa38b2a864b02d952bcedcc4b08d7321699f902f1b1586b7b92eead
|
|
| MD5 |
273c97953f8a49c35ef42994a5655bda
|
|
| BLAKE2b-256 |
c33a9f24768d9159ef20996f0106383ed27602d8fdc7440855c31871a185a44a
|
Provenance
The following attestation bundles were made for pdfbaker-0.11.1.tar.gz:
Publisher:
semantic-release.yaml on pythonnz/pdfbaker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfbaker-0.11.1.tar.gz -
Subject digest:
4b488ac48fa38b2a864b02d952bcedcc4b08d7321699f902f1b1586b7b92eead - Sigstore transparency entry: 611912809
- Sigstore integration time:
-
Permalink:
pythonnz/pdfbaker@036151bd5fe93b6ff3d96d4c2b56967db5efb899 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pythonnz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
semantic-release.yaml@036151bd5fe93b6ff3d96d4c2b56967db5efb899 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdfbaker-0.11.1-py3-none-any.whl.
File metadata
- Download URL: pdfbaker-0.11.1-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5d1221a1ab7b1489b4ed377b08d176ef586282814adb3f48bda34600f7a6b82
|
|
| MD5 |
243123d18a3396d183def7ec180a36c8
|
|
| BLAKE2b-256 |
446b63511937917c539a935cc8aab6d2248b22a01bb69c9c72a5ce59823a8bbc
|
Provenance
The following attestation bundles were made for pdfbaker-0.11.1-py3-none-any.whl:
Publisher:
semantic-release.yaml on pythonnz/pdfbaker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdfbaker-0.11.1-py3-none-any.whl -
Subject digest:
b5d1221a1ab7b1489b4ed377b08d176ef586282814adb3f48bda34600f7a6b82 - Sigstore transparency entry: 611912810
- Sigstore integration time:
-
Permalink:
pythonnz/pdfbaker@036151bd5fe93b6ff3d96d4c2b56967db5efb899 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pythonnz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
semantic-release.yaml@036151bd5fe93b6ff3d96d4c2b56967db5efb899 -
Trigger Event:
push
-
Statement type: