If you've ever written a weekly status report, generated an invoice, or put together a sales deck, you know the drill: build it in one tool, then rebuild it in another when someone asks for a different format. PDF for the client, Word for the editor, PowerPoint for the meeting, Excel for the analyst.
patrakit takes a different approach. You describe the report once — in Python or JSON — and save it to any of the four formats. The same content blocks (headings, tables, charts, KPIs, bullet lists) render into each format following that format's own layout rules.
Install
Python 3.11 or later. No Microsoft Office, LibreOffice, or browser needed.
pip install patrakit PDF output uses Typst through its Python package. Charts use matplotlib. Both are pulled in automatically.
A complete example in 30 lines
Let's build a quarterly sales review and save it to all four formats:
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="Q4 2026", 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 ext in ("pdf", "docx", "pptx", "xlsx"): result = report.save(f"review.{ext}") print(result.path) Output:
review.pdf review.docx review.pptx review.xlsx Four files from one definition. The PDF gets fixed pages, the Word doc gets real heading and table styles, PowerPoint gets editable charts on slides, and Excel gets data sheets with formatted columns.
Content blocks
patrakit gives you eight building blocks that work across all formats:
| Block | What it does |
|---|---|
Heading | Section headers, levels 1–3 |
Text | Paragraphs (blank line = new paragraph) |
BulletList | Bullet points |
KPIRow | Big-number metrics tiles |
Table | Formatted data tables |
Chart | Bar, line, and pie charts |
Image | Embedded images with captions |
Break | Page or slide breaks |
Tables and charts accept a list of dictionaries or a pandas DataFrame. Value formatting handles the common cases: currency:USD, currency:INR, percent:1, integer, date, and more.
Template gallery
patrakit ships with a template gallery of ready-to-use document definitions. Each template is a self-contained Python script with synthetic data that you can download, modify, and run.
# List all templates patrakit templates list # Search by keyword patrakit templates search invoice # Download and run patrakit templates download sales-report ./demo python ./demo/annual_sales_report.py The first five templates cover common document types:
| Template | Category | Formats |
|---|---|---|
| Academic Performance Report | Education | PDF, Word |
| Weekly Project Status Report | Business | PDF, Word |
| Six Years Financial Report | Finance | PDF, Excel |
| Commercial Invoice | Business | PDF, Excel |
| Annual Sales Report | Business | PDF, PowerPoint |
Here's the commercial invoice template — it calculates tax automatically and validates the totals:
from decimal import Decimal from patrakit import Report, Heading, Text, KPIRow, Table line_items = [ {"qty": 2, "description": "Laptop Model ABC", "unit_price": Decimal("600.00"), "amount": Decimal("1200.00")}, {"qty": 1, "description": "Smartphone Model XYZ", "unit_price": Decimal("500.00"), "amount": Decimal("500.00")}, {"qty": 3, "description": "USB Cable", "unit_price": Decimal("10.00"), "amount": Decimal("30.00")}, {"qty": 5, "description": "Headphones Model GHJ", "unit_price": Decimal("50.00"), "amount": Decimal("250.00")}, ] subtotal = sum(item["amount"] for item in line_items) sales_tax = (subtotal * Decimal("0.05")).quantize(Decimal("0.01")) total = subtotal + sales_tax report = Report( title="Commercial Invoice", theme="classic", blocks=[ Heading("From"), Text("Your Company Inc.\n1234 Company St,\nCompany Town, ST 12345"), Heading("Bill To"), Text("Customer Name\n1234 Customer St,\nCustomer Town, ST 12345"), Heading("Invoice details"), KPIRow({"Invoice #": "0000007", "Invoice date": "10-02-2023", "Due date": "10-16-2023"}), Heading("Items"), Table(line_items, formats={ "qty": "integer", "unit_price": "currency:USD", "amount": "currency:USD", }), Heading("Summary"), KPIRow({ "Subtotal": f"${subtotal:,.2f}", "Sales Tax (5%)": f"${sales_tax:,.2f}", "Total (USD)": f"${total:,.2f}", }), Text("Payment is due in 14 days."), ], ) report.save("invoice.pdf") report.save("invoice.xlsx") Themes
Three themes are built in: classic, modern, and minimal. You can also define your own in a YAML file:
# acme.yaml base: modern fonts: heading: Montserrat body: Source Sans 3 colors: primary: "#1F4E79" accent: "#C55A11" 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") JSON input and CLI
The same report can be described in JSON, which is useful for non-Python workflows and AI agents:
{ "schema_version": "1.0", "title": "Quarterly Review", "theme": "modern", "blocks": [ {"type": "heading", "text": "Summary"}, {"type": "kpi_row", "items": [ {"label": "Revenue", "value": "$4.2M"} ]}, {"type": "chart", "chart_type": "bar", "categories": ["North", "South"], "series": [{"name": "Revenue", "values": [1250000, 980000]}]} ] } patrakit validate report.json patrakit render report.json -o report.pdf patrakit render report.json -o report.pptx --theme acme.yaml A JSON Schema is provided at schema/report.schema.json, along with an llms.txt agent guide.
How the formats differ
Each format follows its own rules, so the files share content and style but are not identical:
- Word — Flowing document with real heading, list, and table styles. Charts are images.
- PDF — Fixed pages via Typst. No Office dependency.
- PowerPoint — Each level-1 heading starts a slide. Charts are editable.
- Excel — Summary sheet, plus sheets for tables and editable charts.
What's free and what's planned
Everything described in this article is in the free, open-source package (Apache 2.0). There are no watermarks, page limits, or licence keys.
A Pro version is planned but not on sale yet. It would add premium designs, custom PDF/slide templates, multi-column layouts, and an AI layout planner that uses your own LLM account. Features in the free version will stay free.
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.
patrakit is a single pip install away. Try it on a report you're already building by hand.
bengalaiswaraj-sketch / patrakit
patrakit — Python library to generate Word, PDF, PowerPoint & Excel reports from code or JSON. Create business reports, invoices, dashboards with charts, tables & KPIs. No Office install needed. Free, open-source, Apache-2.0.
patrakit
Describe a report once in Python or JSON. Save it as Word, PDF, PowerPoint or Excel.
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…
``


![At $999, the M5 MacBook Air is hands-down the best value in Macs [Video]](https://9to5mac.com/wp-content/uploads/sites/6/2026/11/MacBook-Air-Best-Value-in-Macs-1.jpg?quality=82&strip=all&w=1600)




