https://github.com/pawel-slowik/htmlpdf
Create PDF documents from YAML data and Jinja2 HTML templates.
https://github.com/pawel-slowik/htmlpdf
cli jinja2 pdf-generation yaml
Last synced: 2 months ago
JSON representation
Create PDF documents from YAML data and Jinja2 HTML templates.
- Host: GitHub
- URL: https://github.com/pawel-slowik/htmlpdf
- Owner: pawel-slowik
- License: mit
- Created: 2020-02-15T22:28:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-05-30T11:18:48.000Z (about 1 year ago)
- Last Synced: 2025-06-28T17:10:59.170Z (12 months ago)
- Topics: cli, jinja2, pdf-generation, yaml
- Language: Python
- Homepage:
- Size: 53.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![Build Status][build-badge]
[![Coverage][coverage-badge]][coverage-url]
[build-badge]: https://github.com/pawel-slowik/htmlpdf/workflows/tests/badge.svg
[coverage-badge]: https://codecov.io/gh/pawel-slowik/htmlpdf/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/gh/pawel-slowik/htmlpdf
A tool for creating PDF documents from YAML data and [Jinja2][jinja2] HTML
templates. Uses the excellent [WeasyPrint][weasyprint] library for rendering
HTML to PDF.
[jinja2]: https://palletsprojects.com/p/jinja/
[weasyprint]: https://weasyprint.org/
## Installation
The script is not packaged, run it from a repository clone. Install
dependencies with:
pip3 install -r requirements.txt
On Debian 12 / Bookworm and 13 / Trixie you can use packages provided by the OS:
sudo apt-get install weasyprint python3-jinja2 python3-yaml python3-unidecode
Or use Docker:
docker compose build
## Usage
Run:
./htmlpdf.py -i input.yaml -t template.html -o output.pdf
With Docker:
docker compose run --rm cmd ./htmlpdf.py -i input.yaml -t template.html -o output.pdf
## Examples
cd examples
../htmlpdf.py -i CV_PL.yaml -t CV_PL.html -o CV_PL.pdf
../htmlpdf.py -i CV_PL.yaml -i CV_star_ratings.yaml -t CV_star_ratings.html -o CV_star_ratings.pdf
With Docker:
docker compose run --rm example1
docker compose run --rm example2
## Development
Run checks and tests:
docker compose run --rm check