Migrating from wkhtmltopdf
wkhtmltopdf turns HTML into PDF by running a whole (old, unmaintained) WebKit. Data-driven reports pay for that on every document: process start, HTML parsing, CSS layout, font discovery. On top of that you deal with XHTML-era quirks such as thead repetition hacks, page-break-inside that only sometimes works, and page numbers via JavaScript in a separate header file.
Liuska takes a different approach. A template is a layout description (a JSON file) plus your data. There is no HTML and no browser. The engine lays out tables natively, paginates them, and writes the PDF directly.
| wkhtmltopdf | Liuska | |
|---|---|---|
| Install | Binary plus Qt/WebKit, system fonts, X libs on Linux | One static binary (Windows, Linux, macOS; amd64 and arm64) |
| Input | HTML + CSS, often generated by a server-side template engine | Template JSON + data JSON/CSV |
| Tables across pages | thead { display: table-header-group }, tr { page-break-inside: avoid }, mixed results |
Built in: header repeated, rows never split |
| Page numbers | Separate --header-html/--footer-html files with a JS subst() script |
{{page}} / {{pages}} in any text |
| Dynamic columns | Loops in your HTML template engine | columnsFrom: the data supplies the column definitions |
| Charts | A JS library (Chart.js, Highcharts, D3) in the page, --javascript-delay so it finishes drawing, often rasterised |
Native vector chart element (bar, line, area, pie, donut, scatter, combo, secondary axis); series can come from the data |
| Number formatting | Done in your code or the HTML template | currency, number, percent, date filters with locale |
| Fonts | Whatever the machine has, which varies between dev and prod | Bundled default plus fonts you ship next to the template, subset into the PDF |
| Throughput | One process per document | liuska serve / batch: warm engine, concurrent renders |
| Benchmark | See bench/ | See the README table |
Concept mapping
| wkhtmltopdf / HTML | Liuska |
|---|---|
--page-size A4, -O Landscape |
"page": { "size": "A4", "orientation": "landscape" } |
-T 20mm -B 20mm -L 15mm -R 15mm |
"page": { "margins": { "top": "20mm", "bottom": "20mm", "left": "15mm", "right": "15mm" } } |
--header-html header.html, --header-spacing |
"header": { "height": 50, "elements": [...] } |
--footer-html footer.html |
"footer": { "height": 30, "elements": [...] } |
<span class="page"></span> / <span class="topage"></span> + subst() JS |
"content": "Page {{page}} of {{pages}}" |
<h1>, <p>, <div> with text |
text element with a named style ("style": "h1") |
<img src="logo.png"> |
image element, src relative to the template, fit: contain |
<hr>, border-bottom on a div |
line element, or stroke on a rect |
Background box (div with background) |
rect with fill and radius |
| CSS classes | styles (named) + defaultStyle |
<table> with <thead> + {% for row in rows %}<tr>… |
table element: data: "rows" + columns |
<th style="text-align:right">Revenue</th> and a formatted <td> |
Column { "key": "revenue", "header": "Revenue", "align": "right", "format": "currency:\"EUR\"" } |
Loop over months to emit <th>/<td> |
columnsFrom: "report.columns" |
tr:nth-child(even) { background } |
altRowStyle: { "fill": "#fafafa" } |
border-collapse + td { border-bottom } |
borders: { "horizontal": {...}, "outer": {...}, "vertical": null } |
<tfoot> / a totals row computed in code |
totals: { "region": "Total", "revenue": "sum" } |
thead { display: table-header-group } |
repeatHeader: true (default) |
tr { page-break-inside: avoid } |
Always on: rows are never split |
<div style="page-break-before: always"> |
{ "type": "pageBreak" } |
| Content that flows after the table | Elements with anchors.top → the table's bottom edge |
<canvas> + new Chart(ctx, { type: "bar", data: { labels, datasets } }) |
chart element: kind: "bar", data = the rows, category.key = the labels, series (or seriesFrom) = the datasets |
Chart.js mixed chart (type: "line" on one dataset, yAxisID: "y1") |
Series "kind": "line", "axis": "right" and axes.y2 |
{% if paid %}…{% endif %} |
visibleIf: "invoice.paid" |
Jinja/Handlebars/Razor {{ customer.name }} |
{{customer.name}}, and filters such as {{ total | currency:"EUR" }} |
--print-media-type, JS, --javascript-delay |
Not needed: nothing executes |
Walk-through: a monthly sales report
A typical wkhtmltopdf setup looks like this:
<!-- report.html, generated by your backend -->
<h1>Sales by region</h1>
<p class="sub">January – October 2026 · EUR</p>
<table class="sales">
<thead><tr>
<th>Region</th><th>Product</th>
{% for m in months %}<th class="r">{{ m.label }}</th>{% endfor %}
<th class="r">Total</th>
</tr></thead>
<tbody>
{% for row in rows %}
<tr><td>{{ row.region }}</td><td>{{ row.product }}</td>
{% for m in months %}<td class="r">{{ row[m.key] | format_number(0) }}</td>{% endfor %}
<td class="r"><b>{{ row.total | format_number(0) }}</b></td></tr>
{% endfor %}
</tbody>
</table>
<p class="notes">{{ notes }}</p>
wkhtmltopdf -O Landscape -T 25mm --header-html header.html --footer-html footer.html report.html report.pdf
To convert it to Liuska:
1. Page and margins. The orientation and margins from the command line go into page:
"page": { "size": "A4", "orientation": "landscape", "margins": { "top": 30, "right": 30, "bottom": 30, "left": 30 } },
"locale": "fi-FI"
2. Header and footer files become bands. Replace header.html (logo plus title) and footer.html (page numbers and their JS) with:
"header": { "height": 50, "elements": [
{ "id": "logo", "type": "image", "src": "logo.png", "x": 0, "y": 2, "width": 107, "height": 32 },
{ "id": "title", "type": "text", "style": "title", "content": "{{report.title}}", "x": 120, "y": 0, "width": 450, "height": 20 },
{ "id": "period", "type": "text", "style": "subtitle", "content": "{{report.period}} · EUR", "x": 120, "y": 21, "width": 450, "height": 14 }
] },
"footer": { "height": 24, "elements": [
{ "id": "pageNo", "type": "text", "align": "right", "content": "Page {{page}} of {{pages}}", "x": 582, "y": 10, "width": 200, "height": 12 }
] }
3. The month loop becomes data. Your backend already knows which months to show. Instead of rendering <th> tags in a loop, it sends column definitions:
"report": {
"columns": [
{ "key": "region", "header": "Region", "width": 82 },
{ "key": "product", "header": "Product", "width": "*" },
{ "key": "2026-01", "header": "Jan", "width": 46, "align": "right", "format": "number:0" },
{ "key": "2026-10", "header": "Oct", "width": 46, "align": "right", "format": "number:0" },
{ "key": "total", "header": "Total", "width": 62, "align": "right", "format": "number:0", "style": { "bold": true } }
],
"rows": [ { "region": "Uusimaa", "product": "Desk 120", "2026-01": 8773.18, "2026-10": 6765.2, "total": 78814.85 } ]
}
The number formatting (format_number(0)) moves into the column format, and locale takes care of the separators.
4. The <table> becomes a table element. The CSS moves into style properties:
{ "id": "sales", "type": "table", "x": 30, "y": 84, "width": "100%",
"data": "report.rows", "columnsFrom": "report.columns",
"headerStyle": { "bold": true, "fill": "#1e293b", "color": "#ffffff" },
"altRowStyle": { "fill": "#f8fafc" },
"cellPadding": 3,
"borders": { "outer": { "color": "#94a3b8", "width": 0.5 }, "horizontal": { "color": "#e2e8f0", "width": 0.5 }, "vertical": null },
"totals": { "region": "Total", "total": "sum" } }
Header repetition and "don't split rows" no longer need CSS hacks.
5. Content after the table gets anchored to it, so it follows the table onto the last page:
{ "id": "notes", "type": "text", "content": "{{report.notes}}", "overflow": "grow", "x": 30, "y": 0, "width": 500, "height": 12,
"anchors": { "top": { "targetId": "sales", "edge": "bottom", "offset": 14 } } }
6. Render and compare.
liuska render -t sales.json -d sales-data.json -o sales.pdf
liuska validate sales.json -d sales-data.json # catches typos in bindings
The complete result is in examples/sales-report/. Your backend now sends JSON instead of rendering HTML. If you already have the HTML-rendering step, you can delete it.
Tip: if you start from a spreadsheet export instead of a typed model, autoColumns: true with a CSV file gets you a working table in two lines. See examples/sales-report-auto/.
Replacing the wkhtmltopdf call in your service
| Before | After |
|---|---|
| Render HTML with your template engine | Build the data object (you already have it) |
Write a temp file and spawn wkhtmltopdf per document |
POST /api/render to liuska serve, or liuska render -d - -o - |
| Parse the exit code and scrape stderr | HTTP status + JSON { error, issues }, or exit codes 0/1/2/3 |
| Batch: a shell loop | liuska batch -d records.ndjson -o out/ -j 8 |
See http-api.md for client snippets (Node, Go, Python, C#).
What is not supported
Liuska is not an HTML renderer. These things do not carry over:
- Arbitrary HTML/CSS: flexbox, grid, floats, CSS selectors, media queries,
@pagerules. Layout is absolute positioning, plus tables that flow and elements anchored under them. - JavaScript: there is no scripting at all, so client-side chart code (Chart.js, Highcharts, D3) won't run. Use the native
chartelement instead: it covers bar, line, area, pie, donut, scatter and combo charts, drawn as vectors. For chart types it doesn't have (maps, gauges, heatmaps), or to keep existing D3 code, run it on the backend (node + jsdom) and place the static SVG output with animageelement: SVG is drawn as vectors with real text, see SVG images. - Rich inline formatting within one text element: mixing bold and normal words, links and inline images inside a paragraph. Use separate text elements, or a style per element.
- Free-flowing documents: long-form text that spans pages like a word processor would. Text boxes
growbut do not break across pages; only tables paginate. - Splitting a row across pages: a single row taller than a page is not split.
- Web fonts and remote resources: no
@font-faceURLs or remote<img>. Ship font files next to the template and use local ordata:images. - Interactive PDF features: forms, links, bookmarks/outlines, table of contents, digital signatures.
- Headers that differ per page (other than
{{page}}/{{pages}}text): there are no first-page-only headers yet. Use body elements on page 1 for a cover-style header. - wkhtmltopdf flags such as
--toc,--cover,--zoomand--dpifor HTML scaling have no equivalent.
If your documents are data-driven (reports, invoices, statements, delivery notes, labels), none of this usually matters, and you get documents that look the same everywhere, generated in milliseconds.