Skip to content

SVG Jinja templates + YAML config = PDF documents

License

Notifications You must be signed in to change notification settings

pythonnz/pdfbaker

Repository files navigation

pdfbaker

Create PDF documents from YAML-configured SVG templates.

Quickstart

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

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 you want to embed particular fonts, they need to be installed. For example for Roboto fonts:

    sudo apt install fonts-roboto

Basic Usage

  1. Create your document design in an SVG editor
  2. Replace text with variables using Jinja2 (e.g., {{ title }})
  3. Configure your content in YAML
  4. Generate PDFs with:
pdfbaker bake <config_file>

This will produce your PDF files in a dist/ directory where your configuration file lives. It will also create a build/ directory with intermediate files, which is only kept if you specify --debug.

Examples

For working examples, see the examples directory.
Create all PDFs with:

pdfbaker bake examples/examples.yml

Documentation

( on GitHub )

Development

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 and run

pre-commit install

This ensures the same checks run locally as in GitHub CI.

About

SVG Jinja templates + YAML config = PDF documents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published