Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 1.88 KB

File metadata and controls

50 lines (31 loc) · 1.88 KB

Litha Almanac Generator

Generate a printable PDF almanac from structured JSON data using Jinja2 templates and WeasyPrint.

Requirements

  • Python 3.10 or newer
  • uv for managing the virtual environment and dependencies (preferred)
  • System packages required by WeasyPrint (e.g. libpango, cairo, gdk-pixbuf, and libffi). Refer to the WeasyPrint installation guide for your platform.

Installation

  1. Install uv (skip if you already have it):

    curl -LsSf https://astral.sh/uv/install.sh | sh

    After installation, ensure that uv is on your PATH (restart your shell if necessary).

  2. Install project dependencies:

    uv sync

    This command creates an isolated virtual environment (by default at .venv/) and installs the packages listed in pyproject.toml.

Usage

Generate the PDF almanac with:

uv run python main.py

The script reads data.json, renders the index.html template with Jinja2, applies style.css, and saves the resulting PDF as almanac.pdf in the project root.

Customizing the Almanac

  • Update data.json to change the content rendered into the template.
  • Modify index.html to adjust the HTML layout or include new data fields. The Jinja2 environment is configured with StrictUndefined, so missing values will cause a helpful error.
  • Edit style.css to tweak typography or layout in the final PDF.

Run uv run python main.py again after making changes to regenerate the PDF.

Troubleshooting

  • If uv reports missing system libraries during installation, install the required packages using your OS package manager and rerun uv sync.
  • For PDF rendering issues, check the console output for template or JSON errors and verify that all paths referenced in the template exist.