Skip to main content

SVG Jinja templates + YAML config = PDF documents

Project description

pdfbaker

PyPI version Python Downloads sigstore tests codecov OSSF Scorecard pip-audit bandit Last commit License

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:

  1. Design your document in an SVG editor or convert to SVG.

  2. 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.

  3. 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.

  4. For future builds, just run:

    pdfbaker myproject/myproject.yaml
    

    to regenerate your PDFs.

Documentation

Examples

For working examples, see the examples directory:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdfbaker-0.11.2.tar.gz (171.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfbaker-0.11.2-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file pdfbaker-0.11.2.tar.gz.

File metadata

  • Download URL: pdfbaker-0.11.2.tar.gz
  • Upload date:
  • Size: 171.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pdfbaker-0.11.2.tar.gz
Algorithm Hash digest
SHA256 12dfd87093030aff651e6a1109b15e629cd4b1a8a87356ed9aff4fc51b57bb94
MD5 8d86f60f4c750794e92c8da598375821
BLAKE2b-256 a1dd7a9b856bf99d04a18aeba2dd15818f86e34226c3f80985f0db5ebde635d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfbaker-0.11.2.tar.gz:

Publisher: semantic-release.yaml on pythonnz/pdfbaker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdfbaker-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: pdfbaker-0.11.2-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

Hashes for pdfbaker-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fcdd37615b708523d95ba03cb498d4a0df7d3db1dc141905e2e5173beae7069a
MD5 5153c162817bf9d20757b93b5d29a253
BLAKE2b-256 f7f021d8c75d677d2e98ddea42152413868265830c8d310ad77d92b9cc8ea3e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdfbaker-0.11.2-py3-none-any.whl:

Publisher: semantic-release.yaml on pythonnz/pdfbaker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page