Skip to content

Repository files navigation

@casoon/renderreport

CICrates.ioDocumentationLicense: MITRust Version

⚠️Early Development Stage - This project is in active early development. APIs may change, and some features are still being implemented and optimized.

Data-driven report generation with Typst as embedded render engine.

Build professional PDF reports without learning Typst. Use components, themes, and template packs to create reports from structured data.

Features

  • Component-based: Build reports using pre-built components (ScoreCard, Finding, Table, etc.)
  • Theme Tokens: CSS-variable-like theming system for consistent styling
  • Template Packs: Extend with custom templates and components
  • Embedded Typst: No CLI dependency, Typst runs as a library
  • Type-safe: Full Rust API with compile-time guarantees

Quick Start

use renderreport::prelude::*;fnmain() -> renderreport::Result<()>{let engine = Engine::new()?;let report = engine
.report("default").title("My Report").add_component(ScoreCard::new("Quality",95)).add_component(Finding::new("Issue Found",Severity::Medium,"Description of the issue")).build();let pdf = engine.render_pdf(&report)?;
std::fs::write("report.pdf", pdf)?;Ok(())}

Installation

Add to your Cargo.toml:

[dependencies]
renderreport = "0.3"

Inspecting the generated Typst source

Engine::render_typ() returns the intermediate .typ source that would be compiled to PDF. Useful for snapshot tests, custom lint/format pipelines (e.g. typstyle), or downstream tooling that wants to post-process the source before compilation.

let source:String = engine.render_typ(&report)?;
std::fs::write("report.typ",&source)?;

Components

59+ production-ready components organized into 8 semantic categories:

  1. Layout & Structure — Section, Grid, Columns, FlowGroup, PageBreak
  2. Text & Editorial — TextBlock, Label, Eyebrow
  3. Metrics & KPIs — ScoreCard, Gauge, BigNumber, TrendTile, ProgressBar
  4. Data & Comparison — AuditTable, ComparisonBlock, Crosstab, PivotTable
  5. Narrative & Storytelling — Finding, QuoteBlock, WhyItMatters, ProblemSolution, BeforeAfter
  6. Infographics — ProcessFlow, Timeline, Funnel, RoadmapBlock, PhaseBlock, WordSearch
  7. Marketing & Sales — ProductHero, FeatureGrid, BenefitStrip, CTABox, PricingCard, Testimonial, UseCaseCard
  8. Media & Assets — Image, Barcode, Sparkline, Chart, List, FaqList, GlossaryList

→ See COMPONENTS.md for complete reference with examples.

Patterns

Pre-configured report structures for common use cases:

  • AuditPattern — Security/compliance audits (findings, impact, roadmap, CTA)
  • MarketingPattern — Product showcases (hero, features, comparison, testimonials, pricing)
  • ExecutivePattern — C-level summaries (metrics, top findings, recommendation, timeline) | Divider | Horizontal separator line | BIRT Band Elements | | Watermark | Background watermark text | Pentaho Watermark | | PageBreak | Force page break | BIRT Page Setup |

Chart Components

Visualize data with comprehensive chart types inspired by JasperReports Chart Components:

ComponentDescriptionChart Types
ChartFull-featured chartsBar, Line, Pie, Area, Scatter, Radar
SparklineInline mini-chartsLine, Bar
GaugeProgress/metric metersCircular, Thermometer, Horizontal

Data Analysis Components

Complex data aggregation inspired by BIRT Cross Tabs and JasperReports Crosstabs:

ComponentDescriptionUse Case
CrosstabDynamic pivot table with aggregationSales by Region × Product
PivotTablePre-aggregated pivot displaySummary reports

Barcode Components

Generate barcodes in multiple formats (inspired by JasperReports Barcode and Pentaho):

ComponentFormats Supported
BarcodeCode128, Code39, EAN-13, EAN-8, UPC-A, UPC-E, QR Code, Data Matrix, PDF417, ITF, Codabar

Text & Field Components

Simple text display inspired by BIRT and Pentaho field elements:

ComponentDescriptionExample Use
LabelSimple styled textHeadings, captions
TextMulti-line text blockParagraphs, descriptions
NumberFieldFormatted numbersCurrency: $1,234.56, Percentage: 87.5%
DateFieldFormatted dates2024-03-15, 15.03.2024, 03/15/2024
ResourceFieldLocalized stringsi18n support

Theming

use renderreport::theme::{Theme,TokenValue};letmut theme = Theme::new("brand","Brand Theme");
theme.tokens.set("color.primary",TokenValue::Color("#1a56db".into()));
theme.tokens.set("color.ok",TokenValue::Color("#059669".into()));let report = engine.report("default").theme(theme)// ...

See docs/CONVENTIONS.md for all available tokens.

Template Packs

Load external packs for specialized reports:

engine.load_pack("seo-audit")?;let report = engine
.report("seo-audit").pack("seo-audit")// ...

Create your own packs with custom templates and components. See @casoon/renderreport-packs.

WebAssembly / Cloudflare Workers

Enable the wasm feature to compile the engine to wasm32-unknown-unknown and run it inside a JS host with no filesystem or system fonts available (e.g. a Cloudflare Worker). Fonts are embedded in the binary as a fallback (EngineConfig::use_embedded_fonts) and picked up automatically whenever no system/font-path fonts are present.

[dependencies]
renderreport = { version = "0.3", default-features = false, features = ["wasm"] }
cargo build --release --target wasm32-unknown-unknown --no-default-features --features wasm
wasm-bindgen target/wasm32-unknown-unknown/release/renderreport.wasm --out-dir pkg --target web
import{initSync,render,render_wordsearch}from"./pkg/renderreport.js";importwasmModulefrom"./pkg/renderreport_bg.wasm";// bundler-provided WebAssembly.ModuleinitSync({module: wasmModule});// Generic report from a RenderRequestconstpdfBytes=render(JSON.stringify(renderRequest));// Purpose-built word search puzzle: title/explanation page, puzzle, solution —// the grid itself is always computed by the real WordSearch engineconstwordSearchPdf=render_wordsearch(JSON.stringify({title: "Animals",words: ["CAT","DOG","OWL"],translations: ["Katze","Hund",null],// optional, per wordlanguage: "en",// "de" | "en" | "fr" | "es"}));

The barcodes feature (Code128/QR/DataMatrix/…) is on by default for native use; disable it with default-features = false on targets where the extra dependency weight isn't needed (as in the wasm example above).

Project Structure

renderreport/
├── src/
│ ├── lib.rs # Main library entry
│ ├── engine/ # Core rendering engine
│ ├── components/ # Standard components
│ ├── theme/ # Theme & token system
│ ├── pack/ # Pack loading system
│ ├── render/ # Typst compilation
│ └── vfs/ # Virtual filesystem
├── templates/ # Built-in Typst templates
├── packs/ # Bundled template packs
├── examples/ # Usage examples
└── docs/ # Documentation

Roadmap

Phase 1: MVP (Current)

  • Core engine with Typst integration
  • Standard component library
  • Theme token system
  • Basic pack loading
  • Full test coverage

Phase 2: Pack System

  • Pack validation & versioning
  • Remote pack loading
  • Pack registry

Phase 3: Ecosystem

  • Preview server for development
  • Visual regression tests
  • HTML output (experimental)
  • WASM support

Related Projects

License

MIT

About

Data-driven PDF report generation in Rust with Typst as the embedded engine — runs natively or as WebAssembly (e.g. Cloudflare Workers).

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages