docs

Liuska

Fast, data-driven PDFs from JSON templates. It replaces wkhtmltopdf for reports, invoices and statements.

You design a template once, in the web designer or as JSON, and then feed it data: a sales report whose month columns come from the data, a dashboard of vector charts, an invoice whose line items push the totals and notes onto the next page, a 10,000-row ledger with the header repeated on every page. liuska lays it out natively and writes the PDF directly. There is no HTML, no headless browser and no system fonts involved.

liuska render -t examples/sales-report/template.json -d examples/sales-report/data.json -o sales.pdf

Why not wkhtmltopdf?

wkhtmltopdf runs an old, unmaintained WebKit for every document. It is heavy to install, slow to start, and stuck on XHTML-era CSS: thead repetition hacks, rows splitting across pages, page numbers through JavaScript in separate header files.

wkhtmltopdf Liuska
Install Qt/WebKit binary, system fonts, X libs on Linux One static binary (Windows/Linux/macOS, amd64/arm64)
Engine Full browser per document No browser. Native layout writes the PDF directly
Tables across pages CSS hacks Built in: repeated header, rows never split, totals
Repeating content Only through --header-html / --footer-html Any element or group can repeat on every page (e.g. a KPI strip), and tables continue below it
Dynamic columns Loops in your HTML templating columnsFrom: the data supplies the columns
Charts A JavaScript chart library plus --javascript-delay, rasterised Native vector chart element: bar, line, area, pie, donut, scatter, combo; series can come from the data
Page numbers JS subst() in header/footer HTML Page {{page}} of {{pages}}
Output consistency Depends on installed fonts Bundled font plus your shipped fonts, subset into the PDF
Service mode One process per document liuska serve: warm engine, concurrent renders

Benchmarks

Measured with bench/ on Windows (Ryzen 9 9950X, 32 threads); rerun with .\bench\run.ps1 or bench/run.sh. wkhtmltopdf wasn't installed on the measuring machine; the harness adds it as extra columns when it's on PATH.

Document Liuska render (cold CLI, p50) Liuska serve (warm) PDF size
1 page, ~10 text elements + 20-row table 19 ms ~19,500 renders/s (p50 1.5 ms) 25 KB
1,000 rows × 8 columns (23 pages) 25 ms ~1,950 renders/s (p50 16 ms) 143 KB
10,000 rows × 8 columns (223 pages) 77 ms 50 renders/s at c=4 (p50 81 ms) 1.2 MB

In-process (go test -bench in renderer/, warm engine): 0.1 ms for the 1-page report, 3.9 ms for 1k rows, 39 ms for 10k rows.

Targets: a one-page render in under 5 ms warm, 1k rows in under 100 ms, 10k rows in under 1 s, a cold CLI render in under 100 ms, and over 200 renders/s from serve.

60-second quick start

  1. Get the binary: download liuska for your platform from Releases, or build it:

    cd generator && go build -o ../liuska .        # Windows: -o ../liuska.exe
  2. Render an example:

    liuska render -t examples/invoice/template.json -d examples/invoice/data.json -o invoice.pdf
  3. Write your own. Save this as hello.json:

    {
      "version": 1,
      "page": { "size": "A4", "margins": { "top": 40, "right": 40, "bottom": 40, "left": 40 } },
      "footer": { "height": 20, "elements": [
        { "type": "text", "align": "right", "content": "Page {{page}} of {{pages}}", "x": 315, "y": 4, "width": 200, "height": 12 } ] },
      "elements": [
        { "type": "text", "fontSize": 20, "bold": true, "content": "Hello {{name}}", "x": 40, "y": 40, "width": 515, "height": 26 },
        { "type": "table", "id": "t", "x": 40, "y": 80, "width": "100%", "data": "rows", "autoColumns": true,
          "headerStyle": { "bold": true, "fill": "#f0f0f0" }, "totals": { "item": "Total", "price": "sum" } }
      ]
    }

    Then render it:

    echo '{"name":"world","rows":[{"item":"Coffee","price":3.5},{"item":"Bun","price":2.9}]}' | liuska render -t hello.json -d - -o hello.pdf

    Add "$schema": "<path>/schema/template.v1.schema.json" to get validation and hover docs in VS Code.

  4. Open the designer: run liuska serve --templates . and go to http://127.0.0.1:8080.

The designer

liuska serve hosts a web designer (React + TypeScript, embedded in the binary). It lets you drag elements onto the page, bind them to data, set up tables with fixed, data-driven or automatic columns, add charts, and see a live preview rendered by the real engine. Templates are saved as plain v1 JSON. See docs/designer.md.

The CLI

liuska render   -t template.json [-d data.json|data.csv|-] [-o out.pdf|-] [--strict] [--png --page N --dpi 96]
liuska validate template.json [-d data.json] [--json]       # exit 3 on errors
liuska batch    -t template.json -d records.ndjson -o outdir/ [--name "{{id}}.pdf"] [-j N]
liuska serve    [--addr 127.0.0.1:8080] [--templates dir] [--editor-dir dir]
liuska version

Data can be JSON or CSV (CSV becomes { "rows": [...] } with numbers detected), and - means stdin/stdout. Exit codes: 0 ok, 1 render error, 2 usage, 3 validation failed. See docs/cli.md.

The HTTP API

curl -X POST http://127.0.0.1:8080/api/render -H "Content-Type: application/json" \
     -d '{"templateName":"invoice","data":{"customer":{"name":"Acme"}}}' -o invoice.pdf

The API has POST /api/render (PDF), /api/preview (PNG), /api/validate, template listing and saving, and /api/healthz. Responses carry X-Liuska-Pages and X-Liuska-Duration-Ms headers. See docs/http-api.md for client snippets in Node, Go, Python and C#.

Documentation

Repository layout

Path What
renderer/ Go rendering engine (package renderer): parse, validate, layout, PDF/PNG output
generator/ The liuska CLI and HTTP server
editor-web/ The web designer (Vite + React + TypeScript), embedded into liuska at release
schema/ JSON Schema for template v1, plus a test that validates the examples
examples/ Example templates with data
docs/ Documentation
bench/ Benchmark harness (Liuska cold/warm vs wkhtmltopdf)
docs-site/ Builds docs.liuska.dev from the Markdown in this repo; see its README
brand/ Logo files (wordmark, mark, app icon, favicons, link preview), colours and usage; see its README
Dockerfile Container image of liuska serve (designer + API, examples as starter templates)
deploy/cloudflare/ Deployment of the public designer to Cloudflare (Worker, static assets, container); see its README
.github/workflows/ CI (vet, test, typecheck, build, schema), release builds, and the manual Cloudflare deploy

Development

go -C renderer test ./...
go -C generator test ./...
cd editor-web && npm ci && npm run dev     # designer on :5173, proxies /api to :8080
cd schema && npm ci && npm test            # validate examples against the schema