Project: ledger-api · Branch: feat/pdf-export · Mode: default · Model: glm-4.6
Summary
Added PDF export for invoices with WeasyPrint and a Jinja2 template; PDFs are rendered in a background task and cached by invoice revision, so re-downloads are instant.
Conversation
Turn 1 — User
Export invoices as PDF. It should look like the HTML preview.
Turn 1 — Assistant
Reuse the HTML preview template, render with WeasyPrint in a background task, store under invoices/<id>/<revision>.pdf. The download endpoint streams the cached file.
Tools used in this turn:
Write: ledger/pdf.pyWrite: templates/invoice.htmlEdit: ledger/routes/invoices.pyBash: pytest tests/test_pdf.py -q — 4 passed
Connections
- [[ledger-api]]
- [[WeasyPrint]]
- [[Jinja2]]
- [[BackgroundTasks]]