patrakit
Describe a report once in Python or JSON. Save it as Word, PDF, PowerPoint or Excel.
Status: pre-release. This README is the specification for version 1.0. The package is not on PyPI yet, so the commands below do not work today.
patrakitis a working name.
Install
Python 3.11 or later.
pip install patrakit
For pandas DataFrames:
pip install "patrakit[pandas]"
PDF output uses Typst through its Python package. You do not need Microsoft Office, LibreOffice or a web browser to create files.
Quickstart
Save this as quickstart.py and run python quickstart.py.
from patrakit import Report, Heading, Text, KPIRow, Table, Chart
sales = [
{"region": "North", "revenue": 1250000, "growth": 0.12},
{"region": "South", "revenue": 980000, "growth": 0.07},
{"region": "East", "revenue": 1120000, "growth": 0.09},
{"region": "West", "revenue": 850000, "growth": -0.03},
]
report = Report(
title="Quarterly Sales Review",
subtitle="Synthetic demo data",
theme="modern",
blocks=[
Heading("Summary"),
Text("Revenue grew in three of four regions."),
KPIRow({"Revenue": "$4.2M", "New accounts": 128}),
Heading("Revenue by region", level=2),
Chart.bar(
sales,
x="region",
y="revenue",
title="Revenue by region",
alt_text="Bar chart comparing revenue in four regions",
),
Table(sales, formats={"revenue": "currency:USD", "growth": "percent:1"}),
],
)
for extension in ("docx", "pdf", "pptx", "xlsx"):
result = report.save(f"review.{extension}")
print(result.path)
for warning in result.warnings:
print(f" {warning.code}: {warning.message}")
You get four files from one report definition. Each format follows its own layout rules, so the files share content and style but do not look identical.
Gallery
Each image must come from the code beside it. scripts/build_gallery.py runs the files in
gallery/snippets/ and creates the images. All data is synthetic.
Word, PowerPoint and Excel pages are rendered for these images with LibreOffice. They can look slightly different in Microsoft Office.
| Code | Real output |
|---|---|
from patrakit import Report, KPIRow, Chart
sales = [
{"region": "North", "revenue": 1250000},
{"region": "South", "revenue": 980000},
]
Report(
title="Sales Review",
blocks=[
KPIRow({"Revenue": "$2.23M"}),
Chart.bar(sales, x="region",
y="revenue"),
],
).save("sales.pdf")
|
|
Word
| Code | Real output |
|---|---|
from patrakit import (
Report, Heading, BulletList)
Report(
title="Weekly Status",
blocks=[
Heading("Done this week"),
BulletList([
"Login flow shipped",
"12 bugs closed",
]),
],
).save("status.docx")
|
|
PowerPoint
| Code | Real output |
|---|---|
from patrakit import Report, Heading, Chart
mrr = [
{"month": "Sep", "mrr": 41000},
{"month": "Oct", "mrr": 44500},
{"month": "Nov", "mrr": 47200},
]
Report(
title="SaaS Monthly Review",
blocks=[
Heading("MRR trend"),
Chart.line(mrr, x="month", y="mrr"),
],
).save("saas.pptx")
|
|
Excel
| Code | Real output |
|---|---|
from patrakit import Report, Heading, Table
runs = [
{"model": "model-a", "pass_rate": 0.91},
{"model": "model-b", "pass_rate": 0.87},
]
Report(
title="Evaluation Results",
blocks=[
Heading("Pass rate"),
Table(runs, formats={
"pass_rate": "percent:1"}),
],
).save("evals.xlsx")
|
|
Five runnable examples
The examples are included in the package, so you do not need to clone the repository.
patrakit examples list
patrakit examples copy invoice ./demo
python ./demo/invoice.py
| Name | Script | Creates | Needs | Guide |
|---|---|---|---|---|
saas-monthly-review |
saas_monthly_review.py |
PowerPoint, PDF | patrakit |
Create a SaaS monthly review in PowerPoint and PDF with Python |
invoice |
invoice.py |
PDF, Excel | patrakit |
Generate an invoice PDF and Excel file in Python |
project-status |
project_status.py |
Word, PDF | patrakit |
Automate a weekly project status report in Word with Python |
analytics |
analytics_report.py |
Word, PDF | patrakit[pandas] |
Pandas DataFrame to a Word and PDF report |
ai-evaluation |
ai_evaluation_report.py |
PDF, Excel | patrakit |
Turn LLM evaluation results into a PDF and Excel report in Python |
All examples use made-up data and need no API key. The invoice is a layout example. It does not claim to meet the tax or legal invoice rules of any country.
What is free
Every feature in this section is in the free package. There are no watermarks, page limits, accounts or licence keys.
Content blocks
| Block | Example |
|---|---|
| Heading, levels 1 to 3 | Heading("Summary", level=1) |
| Text; a blank line starts a new paragraph | Text("Revenue grew.") |
| Bullet list | BulletList(["One", "Two"]) |
| KPI row | KPIRow({"Revenue": "$4.2M"}) |
| Table | Table(rows, formats={"amount": "currency:INR"}) |
| Bar, line and pie charts | Chart.bar(rows, x="month", y="sales") |
| Image | Image("logo.png", alt_text="Company logo", width=0.4) |
| Page or slide break | Break() |
Tables and charts accept a list of dictionaries. With the pandas extra, they also accept
a DataFrame. Image width is a share of the content width, from 0 to 1.
Value formats
| Format | Input | Shown as |
|---|---|---|
text |
North |
North |
integer |
1250000 |
1,250,000 |
number:2 |
3.14159 |
3.14 |
percent:1 |
0.12 |
12.0% |
currency:USD |
1250000 |
$1,250,000.00 |
currency:INR |
1250000 |
₹12,50,000.00 |
date |
datetime.date(2026, 11, 29) |
29 Nov 2026 |
patrakit formats values. It does not convert currencies or calculate totals.
Themes
Three themes are built in: classic, modern and minimal. You can also load your own
theme file.
# acme.yaml
base: modern
fonts:
heading: Montserrat
body: Source Sans 3
table: Source Sans 3
code: JetBrains Mono
fallback: [Noto Sans]
font_dirs: [./fonts]
colors:
primary: "#1F4E79"
accent: "#C55A11"
text: "#1F2328"
logo: assets/logo.png
header: "Acme Pvt Ltd"
footer: "Confidential"
from patrakit import Report, Text, Theme
report = Report(
title="Board Update",
theme=Theme.load("acme.yaml"),
blocks=[Text("All milestones are on track.")],
)
report.save("update.pdf")
Paths in a theme file are relative to that file. The code font role is reserved because
version 1 has no code block.
Custom fonts
Set one font family for everything, or set each role:
from patrakit import Report, Text, Theme, Fonts
theme = Theme(base="classic", fonts=Fonts(family="Noto Sans", font_dirs=["./fonts"]))
report = Report(title="Notes", theme=theme, blocks=[Text("Hello")])
report.save("notes.pdf", strict_fonts=True)
- Fonts come from your computer or your
font_dirs. patrakit does not download fonts. - A missing font produces a warning and uses a fallback. With
strict_fonts=True, saving fails instead. - Word, PowerPoint and Excel files store font names, not the fonts. The reader's
computer needs the same fonts. Use
Fonts.office_safe()when you share these files. PDF creation may need those fonts on your own computer too. - Built-in themes use Office-safe names in Office files and bundled open fonts in PDF. A font that you choose applies to all four formats.
- Support for a writing system is claimed only after it is tested. Check your output.
- You are responsible for the licences of fonts you add.
Run patrakit fonts to list the font families that patrakit can find.
JSON input and command line
You can describe the same report in JSON. This is useful for other programming languages and AI agents.
{
"schema_version": "1.0",
"title": "Quarterly Sales Review",
"theme": "modern",
"blocks": [
{"type": "heading", "level": 1, "text": "Summary"},
{"type": "text", "text": "Revenue grew in three of four regions."},
{"type": "kpi_row", "items": [{"label": "Revenue", "value": "$4.2M"}]},
{"type": "bullet_list", "items": ["North grew 12%", "West fell 3%"]},
{
"type": "chart",
"chart_type": "bar",
"title": "Revenue by region",
"alt_text": "Bar chart comparing revenue in four regions",
"categories": ["North", "South", "East", "West"],
"series": [{"name": "Revenue", "values": [1250000, 980000, 1120000, 850000]}]
},
{
"type": "table",
"columns": [
{"key": "region", "label": "Region", "format": "text"},
{"key": "revenue", "label": "Revenue", "format": "currency:USD"}
],
"rows": [
{"region": "North", "revenue": 1250000},
{"region": "South", "revenue": 980000}
]
}
]
}
patrakit validate report.json
patrakit render report.json -o report.pdf
patrakit render report.json -o report.pptx --theme acme.yaml --strict-fonts
patrakit schema -o report.schema.json
From Python, use Report.from_file("report.json") for a file, or Report.from_json(data)
for a JSON string or dictionary.
Image paths must stay inside the report's asset folder. For a JSON file, that is the folder that contains it. patrakit does not load images from web addresses.
For AI agents
- JSON Schema:
schema/report.schema.json - Agent guide:
llms.txt - A small MCP server is planned for a later release.
A good agent workflow is: read the schema, create the JSON, run patrakit validate,
then run patrakit render and read the warnings.
How each format behaves
| Format | Behaviour | Version 1 limits |
|---|---|---|
| Word | Flowing document with real heading, list and table styles | Charts are images, so you cannot edit their data in Word |
| Fixed pages | Accessibility and archival standards are not claimed | |
| PowerPoint | Each level 1 heading starts a slide; long content continues on new slides; charts are editable | Check slides for fit before you present them |
| Excel | A summary sheet, plus sheets for tables and editable charts | Values only; no generated formulas |
patrakit creates new documents. It does not edit existing ones, accept HTML as input or offer a visual designer.
Privacy
The free package makes no network calls, calls no AI service and collects no usage data.
Your report stays on the machine that runs the code. Installing packages with pip uses
the network as usual.
Free and Pro
patrakit Pro is planned and not on sale yet.
| Feature | Free | Pro (planned) |
|---|---|---|
| All content blocks and JSON Schema | ✓ | ✓ |
| Word, PDF, PowerPoint and Excel output | ✓ | ✓ |
| Three built-in themes and your own theme file | ✓ | ✓ |
| Choose fonts for each role | ✓ | ✓ |
| Premium report designs | ✓ | |
| Your own PDF and slide templates | ✓ | |
| Advanced PDF layouts: multi-column, dashboard, cover page | ✓ | |
| AI layout planner that uses your own LLM account | ✓ | |
| Your own Excel templates (after the first Pro release) | ✓ | |
| Bulk rendering (later) | ✓ |
Features in the free column will stay free.
In Pro, you choose your LLM provider in one configuration file,
patrakit.llm.yaml: Gemini, OpenAI, or an endpoint compatible with the OpenAI Chat
Completions API, including a local one. The AI suggests a layout. It does not draw the
document or rewrite your values. In the free package, layout="ai" and template= raise
FeatureNotAvailableError.
See the Pro page for sample files, proposed prices and draft terms.
Help and contributing
- Report a bug or ask for a feature with a GitHub issue. Include a small example with made-up data. Never post API keys or private business data.
- Support for the free package is on a best-effort basis.
- Read
CONTRIBUTING.mdbefore you open a pull request. Report security problems as described inSECURITY.md.
Licence
The free package uses the Apache License 2.0. See LICENSE. Libraries and bundled fonts
keep their own licences. See THIRD_PARTY_NOTICES.md. patrakit Pro will have a separate
commercial licence.
Metadata
Release files for patrakit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| patrakit-0.1.1.tar.gz | 43.2 kB | With provenance | Details for patrakit-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patrakit-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for patrakit-0.1.1-py3-none-any.whl |
Total release size: 90.9 kB
Release files / patrakit-0.1.1.tar.gz
| Download URL | patrakit-0.1.1.tar.gz |
|---|---|
| Size | 43.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b90ef93c121f45f95198eb41c6869bfea9464fb4e2b8ae9377d61de51b93875
|
|
BLAKE2b-256 checksum How to use checksums |
25af30ce7178fd8279ce0e16841ca617ca380094fcaef21c4518c3be635d50d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / patrakit-0.1.1-py3-none-any.whl
| Download URL | patrakit-0.1.1-py3-none-any.whl |
|---|---|
| Size | 47.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
622100ec31e4571f5377696b4c8f99f663977cd88e4e35f7d54d81ad39661b79
|
|
BLAKE2b-256 checksum How to use checksums |
bfdad7655b472f2f67445dec778956ad910a532f714eafdc89cfeb1fee0a7f96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for patrakit 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for patrakit-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.