Skip to main content

ReportKit

A developer-first document generation engine with flow-based layout system for PDF and DOCX documents.

Features

  • Flow-based Layout: Stream-based document layout (no absolute positioning)
  • Dynamic Pagination: Automatic page breaks and content splitting
  • JSON Templates: Declarative template system with v1 standard
  • AI Design Importer: [NEW] Automatically generate templates from Figma screenshots
  • Data Binding: Jinja2-style variable binding
  • Multiple Formats: PDF, DOCX, and HTML output
  • Plugin System: Extensible block architecture
  • Production Ready: Pip-installable Python package
  • Visual Designer: Professional drafting tool for creating templates

Quick Start

Installation

pip install reportkit

To enable AI-powered design importing:

pip install "reportkit[ai]"

AI Setup (Bring Your Own Key): The AI importer requires a Google AI API key.

  1. Get a free API key from Google AI Studio.
  2. Set it as an environment variable (GOOGLE_API_KEY) or in a .env file in your project root:
GOOGLE_API_KEY=your_key_here

Note: The AI Design Importer (Phase A) currently requires the designer to be run locally as it utilizes a local AI server for the BYOK (Bring Your Own Key) method.

For PDF rendering, also install Playwright:

pip install playwright
playwright install chromium

For DOCX rendering, install docxtpl:

pip install docxtpl

ReportKit Designer

Create templates visually using our professional drafting tool.

The designer features a Photoshop-like environment with millimeter-precision rulers, a grid system, and real-time multi-column pagination preview.

Basic Usage

from reportkit import ReportEngine

# Create engine
engine = ReportEngine()

# Register template
engine.register_template("sales_report", "templates/sales.json")

# Render report
report = engine.render(
    "sales_report",
    data={
        "client": {"name": "ABC Corporation"},
        "sales": [
            {"product": "Widget A", "amount": 1500},
            {"product": "Widget B", "amount": 2300},
        ],
        "total": 3800
    }
)

# Export to different formats
report.to_pdf("sales_report.pdf")
report.to_docx("sales_report.docx")
report.to_html("sales_report.html")

Template System

ReportKit uses JSON-based templates with a flow-based layout system:

{
  "version": "1.0",
  "name": "Sales Report",
  "page_config": {
    "size": "A4",
    "orientation": "portrait",
    "margins": {
      "top": 72,
      "right": 72,
      "bottom": 72,
      "left": 72
    }
  },
  "groups": [
    {
      "id": "header",
      "flow": "block",
      "page_behavior": "keep_together",
      "blocks": [
        {
          "type": "text",
          "data": {
            "content": "Sales Report for {{client.name}}"
          },
          "style": {
            "font_size": 18,
            "font_weight": "bold",
            "alignment": "center"
          }
        }
      ]
    },
    {
      "id": "content",
      "flow": "block",
      "page_behavior": "can_split",
      "blocks": [
        {
          "type": "table",
          "data": {
            "headers": ["Product", "Amount"],
            "data": "{{sales}}"
          }
        },
        {
          "type": "text",
          "data": {
            "content": "Total: ${{total}}"
          },
          "style": {
            "font_weight": "bold"
          }
        }
      ]
    }
  ]
}

Block Types

Text Block

{
  "type": "text",
  "data": {
    "content": "Hello {{name}}!"
  },
  "style": {
    "font_family": "Arial",
    "font_size": 12,
    "color": "#000000",
    "alignment": "left"
  }
}

Image Block

{
  "type": "image",
  "data": {
    "source": "logo.png",
    "width": 200,
    "height": 100,
    "alt_text": "Company Logo"
  }
}

Table Block

{
  "type": "table",
  "data": {
    "headers": ["Name", "Age", "City"],
    "data": [
      ["John", 30, "New York"],
      ["Jane", 25, "Boston"]
    ]
  },
  "options": {
    "show_headers": true,
    "border": true,
    "striped": false
  }
}

Chart Block

{
  "type": "chart",
  "data": {
    "chart_type": "bar",
    "title": "Sales by Month",
    "labels": ["Jan", "Feb", "Mar"],
    "datasets": [
      {
        "label": "Sales",
        "data": [1000, 1500, 1200],
        "color": "#007bff"
      }
    ]
  },
  "options": {
    "width": 400,
    "height": 300,
    "legend": true
  }
}

Page Behavior

Groups can have different page break behaviors:

  • normal_flow: Default flow behavior
  • keep_together: Group stays on same page
  • can_split: Group can split across pages
  • start_new_page: Group always starts on new page

Custom Blocks

Create custom block types by extending BaseBlock:

from reportkit.blocks import BaseBlock, BlockContext

class CustomBlock(BaseBlock):
    type = "custom"
    
    def validate(self, data):
        # Validate block data
        pass
    
    def render(self, data, context: BlockContext):
        # Render block to intermediate format
        return {
            "type": "custom",
            "content": "...",
            "style": {}
        }

# Register custom block
engine.register_block(CustomBlock)

Development

Setup

git clone https://github.com/uju11/reportkit
cd reportkit
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

black reportkit
isort reportkit

Architecture

ReportKit follows a clear rendering pipeline:

  1. Template Parsing → Validate JSON template
  2. Data Binding → Resolve variables with Jinja2-style binding
  3. Layout Resolution → Create flow-based document tree
  4. Pagination → Handle page breaks and content splitting
  5. Rendering → Convert to HTML, then PDF/DOCX

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Support

Metadata

Release files for reportkit 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reportkit 0.1.2
File Size Uploaded Provenance
reportkit-0.1.2.tar.gz 43.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for reportkit 0.1.2
File Interpreter ABI Platform
reportkit-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 95.2 kB

Release files / reportkit-0.1.2.tar.gz

Download URL reportkit-0.1.2.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
160651c99cfddcc5957fa78d12b345eb903731f8b411d2595f0d1fe49e3cb2e8
BLAKE2b-256 checksum
How to use checksums
f92ffbeef4b1ade81ccda655a1010896f7223939d924c39ce6b02e0c5360d9f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / reportkit-0.1.2-py3-none-any.whl

Download URL reportkit-0.1.2-py3-none-any.whl
Size 52.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11cd2554b161e4a95e406a28d8233fa9723ab7f796b200fb05d493d262ebf295
BLAKE2b-256 checksum
How to use checksums
83ee5a9ebf7438455ba206369b7214130f3380ad521557a650a70ed914dc8dc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for reportkit 0.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page