Tabular PDF reports, from Python.
Hierarchical layouts, Jinja2 rendering and Playwright PDF. One function call from data
to a print-ready document — sync or async, from a Python dict or a
compact .toon file.
- Python
- MIT
- PyPI v0.4.0
- Jinja2
- Playwright
What it does
From nested records to a polished PDF.
-
Hierarchical layouts
Nested groups become sections; flat child lists render as tables. The document adapts to the data instead of rigid bands.
-
JSON or
.toonPass a
dict/ReportPayloador a compact indented.toondocument with the same structure. -
Jinja2 templates
Templates are bundled in the package. Point
template_dirat your own directory to override the layout or reuse its macros. -
Playwright PDF
Chromium renders the final document. The sync API opens and closes the browser per call; the async API reuses a shared pool.
-
Sync and async
generate_pdf,agenerate_pdfandrender_htmlfor the intermediate HTML — no browser needed for the latter. -
Locale-aware masks
str,int,float,date,percent,currencyandbool— via Babel/CLDR, withpt-BR,en-USand more.
Quick start
Python package + Chromium for PDF rendering.
pip install isis-report-lib
playwright install chromium
from isis_report_lib import generate_pdf
payload = {
"meta": {"title": "Sales Order", "sub_title": "2024", "mode": "exact"},
"layout": {
"company": {"label": "Company", "format_mask": "str", "alignment": "left"},
"orders": {
"order": {"label": "Code", "format_mask": "int", "alignment": "right"},
"total": {"label": "Total", "format_mask": "float", "alignment": "right"},
},
},
"data": [
{"company": "ACME", "orders": [{"order": 750, "total": 4000}]},
],
}
pdf = generate_pdf(payload)
open("report.pdf", "wb").write(pdf)
# Async
from isis_report_lib import agenerate_pdf
pdf = await agenerate_pdf(payload)
# Intermediate HTML, without a browser
html = render_html(payload)
# CLI
isis-report generate examples/sales_order.toon -o report.pdf
isis-report render examples/sales_order.toon -o report.html
After upgrading Playwright, reinstall the browser: each Playwright version pins a specific Chromium build.
Payload at a glance
Declarative behavior, not a rigid template.
| Field | What it controls |
|---|---|
meta |
Title, subtitle, mode, locale, currency, accent color, page size/orientation and
printed_at (auto-filled).
|
layout |
Hierarchical field definitions — labels, masks, alignment, visibility. Omit to infer from the data. |
data |
Raw records or the template format with nested groups. |
aggregate |
sum, count, avg, min,
max — group footers, detail footers and grand summaries.
|
$print_when |
Keep only rows matching a field condition. |
$order_by |
Sort rows by one or more fields, with nulls last. |
visible / visible_when |
Hide a column, conditionally. |
Links
- PyPI packagepip install isis-report-lib
- Source & examplesgithub.com/thepaneb/isis-report-lib
- ReleasesChangelog and published versions
- isis_reportThe HTTP/MCP service built on this library
Templates are code: only load template_dir from sources you trust. Report
data is never executed as template code — it is interpolated only.