isis-report-lib 0.1.1

Tabular reports with hierarchical layouts: HTML, PDF, XLSX, CSV and plain text
Documentation

isis-report-lib (Rust)

CI crates.io docs.rs MSRV License

A Rust port of isis-report-lib: tabular reports with hierarchical layouts, rendered to HTML, PDF, XLSX, CSV and plain text.

The Python library remains the behavioral reference. The scripts in parity/ generate the golden fixtures in crates/isis-report-lib/tests/fixtures/golden/.

Features

Feature Enables
pdf (enabled by cli) Chromium/CDP PDF backend (chromiumoxide + Tokio), pooled per process
xlsx Native Excel workbook, charts, data bars and conditional formats
email CSS inlining for email-friendly HTML
sign Ed25519 signatures (HMAC-SHA256 is always available)
arrow from_arrow / from_arrow_batch payload builders
polars from_polars payload builder
duckdb from_duckdb / from_duckdb_connection builders
sqlite from_sqlite / from_sqlite_connection builders
schema Payload JSON Schema (default)
cli isis-report binary and all browser/export features
weasyprint-cli Optional external weasyprint PDF shim

Usage

use isis_report_lib::{generate_xlsx, render_html, Value};

let payload = Value::from_json(serde_json::json!({
    "meta": {"title": "Sales", "locale": "pt-BR"},
    "layout": {
        "company": {"label": "Empresa", "format_mask": "str"},
        "orders": {
            "total": {"label": "Total", "format_mask": "currency", "aggregate": "sum"}
        }
    },
    "data": [
        {"company": "ACME", "orders": [{"total": 1250.5}]}
    ]
}));

let html = render_html(&payload, None, "tabular.jinja", false, None)?;
let xlsx = generate_xlsx(&payload, None)?;
# Ok::<(), isis_report_lib::Error>(())

PDF:

use isis_report_lib::{generate_pdf, generate_pdf_with, PdfOptions};

let pdf = generate_pdf(&payload, None)?;

let options = PdfOptions {
    landscape: true,
    page_ranges: Some("1-3".to_string()),
    ..PdfOptions::default()
};
let pdf = generate_pdf_with(&payload, &options, None, "tabular.jinja", None)?;
# Ok::<(), isis_report_lib::Error>(())

The sync API starts a private Tokio runtime; async callers should use generate_pdf_async / generate_pdf_with_async instead. PDF generation uses a process-wide pool of Chromium workers (one browser per worker), so consecutive reports avoid a launch. Pages run with JavaScript disabled, service workers bypassed and outbound HTTP(S) blocked unless allowed_hosts is set. Call isis_report_lib::shutdown_pdf_pool() to close the workers in a long-lived process; the CLI does this automatically. ISIS_REPORT_PDF_WORKERS (1-8) controls the pool size and ISIS_REPORT_PDF_IDLE_SECS (default 300, 0 disables) closes idle browsers. pdf_pool_stats() reports workers, in-flight jobs, browser launches, renders and idle closes. Run the pdf_throughput example to compare cold and warm renders.

debug_dir writes report.html, a full-page report.png and a real Chrome Trace Format dump (trace.json) from CDP. It may contain report data; protect or delete it after use.

Examples

Runnable examples are in crates/isis-report-lib/examples:

cargo run -p isis-report-lib --example quickstart
cargo run -p isis-report-lib --example inputs
cargo run -p isis-report-lib --features xlsx --example xlsx
cargo run -p isis-report-lib --example signing
cargo run -p isis-report-lib --features pdf --example pdf_throughput

The crate-level docs also include a compiling quickstart.

Input builders

# #[cfg(feature = "sqlite")]
# fn demo() -> isis_report_lib::Result<()> {
use isis_report_lib::from_sqlite;

let payload = from_sqlite("sales.db", "SELECT * FROM sales", None, None)?;
# Ok(())
# }
  • from_arrow(&[RecordBatch], meta, layout) / from_arrow_batch(&RecordBatch, ...)
  • from_polars(&DataFrame, meta, layout)
  • from_duckdb(path, Some(query), meta, layout) or from_duckdb_connection
  • from_sqlite(path, query, meta, layout) or from_sqlite_connection
  • from_rows(columns, rows, meta, layout) for any DB-API-style driver

Dates, datetimes and decimals are kept as native Value variants; NaN is normalized to Null.

CLI

cargo install isis-report-lib --features cli
isis-report generate report.json -o report.pdf --locale pt-BR
isis-report generate report.json -o report.xlsx
isis-report generate report.json --format csv --bom
isis-report render report.json --format html -o report.html
isis-report schema
isis-report keygen --kind hmac -o key.bin
isis-report sign report.pdf --key-file key.bin -o report.signed.pdf
isis-report verify report.signed.pdf --key-file key.bin --json

PDF flags: --page-format, --header-template, --footer-template, --allowed-hosts (repeatable), --debug-dir.

Design

  • Payload contract: meta + optional layout + data, or composed sections; strict envelope validation (unknown keys fail closed).
  • Dynamic values: a Value enum compatible with JSON, with native date/datetime/decimal variants for database/columnar inputs.
  • Python semantics: ordering (None last), equality (10 == 10.0, True == 1), str()/repr(), truthiness and in are isolated in pyops.
  • Safety: no payload value is echoed in errors/logs; quotas, depth limits, data-URI-only images and strict template autoescape are part of the design.
  • Locales: the 13-locale matrix (pt-BR, en-US, pt-PT, de-DE, fr-FR, es-ES, ja-JP, ar-EG, he-IL, ru-RU, zh-CN, hi-IN, en-GB) matches Babel for numbers, currency and medium dates; locales outside the matrix use ICU4X/CLDR and may differ in edge cases.

Workspace

crates/isis-report-lib   # public library + `isis-report` binary + PDF backend
crates/isis-report-pdf   # compatibility facade (publish = false)
parity/                  # Python fixture generators
crates/isis-report-lib/tests/fixtures/golden  # generated golden fixtures

Documentation

Testing

cargo test --workspace --all-features
cargo clippy --workspace --all-features --all-targets -- -D warnings
cargo fmt --all -- --check
cargo llvm-cov --workspace --all-features --summary-only -- --include-ignored --test-threads=1

The coverage command also requires Chrome because it includes the PDF e2e tests. PDF browser tests are ignored by default because they require a local Chromium/Chrome:

cargo test -p isis-report-lib --features pdf pdf_backend::tests:: -- --ignored --test-threads=1

CI runs formatting, clippy, the full test suite on Linux, the cli suite and full Chromium PDF e2e on Windows/macOS, a dedicated Chromium PDF e2e job on Linux, cargo-deny, and an MSRV check with Rust 1.89.

Fuzzing targets for TOON, payload/layout, HTML rendering and signatures live in fuzz/ and run on a weekly GitHub Actions schedule.

Benchmarks

Criterion benchmarks cover shaping, HTML rendering, CSV/XLSX export and TOON parsing:

cargo bench -p isis-report-lib --features xlsx --bench pipeline

The PDF benchmark needs a local Chromium/Chrome:

cargo bench -p isis-report-lib --features pdf --bench pdf

Criterion writes HTML reports under target/criterion/. The workload matches the Python benchmark (5 orders, 300 detail rows) so medians are comparable; PDF timings include browser-pool warmup and should be compared on the same machine.

CI also runs a smoke-level performance gate with generous budgets:

cargo run --release -p isis-report-lib --features cli --example perf_check

Use -- --no-pdf to skip the Chromium step locally. Budgets live in crates/isis-report-lib/benches/budgets.json; the gate catches pathological regressions, not small drifts.

License

MIT - see LICENSE.