Modern JavaScript
ES2022+ through the Boa engine. React 18, Vue 3 and Preact apps render, timers included, on a virtual clock that never waits for real time.
Open source · Rust · GPL-3.0
A modern successor to wkhtmltopdf. bdhtml2pdf runs your page's JavaScript, styles it with Firefox's CSS engine and writes a PDF with real, searchable text. No Chromium, no WebKit, no Qt.
$ bdhtml2pdf invoice.html invoice.pdf
Pre-release 0.1.0. It works end to end and every number on this page is measured, but it still builds against patched checkouts of fulgur and Blitz until our upstream pull requests are merged. See the known issues.
Features
Templates for invoices, reports, certificates and tickets are HTML, and more and more of that HTML is built by JavaScript. bdhtml2pdf renders it as it is.
ES2022+ through the Boa engine. React 18, Vue 3 and Preact apps render, timers included, on a virtual clock that never waits for real time.
Stylo, the cascade Firefox ships, not a hand-written subset: nesting, :has(), @layer, grid, flex, multi-column, oklch(), color-mix().
Text stays text, so it can be searched and copied. Fonts are subset. @page, margin boxes, running headers, page counters and repeated table headers work.
One 31 MB binary and one process. About 30–50 MB of memory and 0.07 s for a typical page; a React app with timers takes 0.16 s.
No network access. Files load only from the input's directory. Endless loops, timer floods and memory bombs are stopped by built-in limits.
PNG and JPEG with --width, --height, --zoom and --quality, like wkhtmltoimage. They come from the same layout as the PDF.
Samples
Every document below was produced by bdhtml2pdf from a single HTML file; the previews show the first page of each PDF. Open a PDF and select its text, or read the HTML source.
KPI cards, a table and an SVG chart, all built by JavaScript. Grid layout, color-mix(), three columns of text.
Line items and VAT computed by a script, Turkish lira formatting, and a footer with “Page 1 of 1” from @page margin boxes.
Three columns that flow around floated figures, a headline spanning the columns, and columns that continue on page two.
Landscape A4 in Turkish, an SVG seal with text on a path, and text-transform under lang="tr": ılgın → Ilgın.
How it works
Every hard part already existed as a maintained Rust library. bdhtml2pdf connects them into one pipeline with one DOM and one style engine, and sends every change it needs upstream as a pull request.
@page, margin boxes, counters, table and column breaks| Library | Role |
|---|---|
| Blitz | DOM, style and layout glue, and the JavaScript binding |
| Stylo | CSS cascade, the engine Firefox uses |
| Taffy · Parley | block, flex and grid layout · text shaping and line breaking |
| Boa | JavaScript engine, written in Rust |
| fulgur | paged media and pagination; ported by us to current Blitz |
| Krilla · hayro | PDF writer · PDF rasterizer for image output |
Results
The same pages went through four engines with default settings on one machine (i7-12800H, Fedora 45, median of 5 runs, 19 November 2026). Results are read back from the PDFs; nothing is judged by eye.
| Check | bdhtml2pdf 0.1.0 | sghtmltopdf 0.8.0 | wkhtmltopdf 0.12.6 | Chromium 157 |
|---|---|---|---|---|
| Modern CSS (11) | 10 | 8 | 1 | 11 |
| Modern JavaScript (19) | 18 | 0, no JS | 0, no ES2015+ | 18–19 |
| React, Vue, Preact apps | 3/3 | 0/3 | 0/3 | 3/3 |
| HTML parsing (7) | 7 | 7 | 6 | 7 |
| Turkish (15) | 12 | 8 | 8 | 14 |
| Fonts (8) | 7 | 7 | 6 | 8 |
| One-page document | 0.07 s | 0.02 s | 0.24 s | 0.36 s |
| React app with timers | 0.16 s | — | — | 0.38 s |
| 24-page invoice | 1.07 s | 0.08 s | 0.37 s | 0.71 s |
bdhtml2pdf is the only engine besides Chromium that runs modern JavaScript apps and modern CSS, with about an eighth of its memory. It is slower than the JavaScript-free sghtmltopdf on static pages and slower than all of them on very long tables. The install size was 25 MB in the benchmark run and is 31.5 MB since image output was added. Full results and method.
Security
HTML-to-PDF services often render documents that users control. The security suite tries to read local files, escape the input directory, reach internal services and exhaust the machine, with every engine on its default settings.
/etc/passwd through iframes, objects, redirects or fetch()wkhtmltopdf 9/11 · headless Chromium 1/11
while (true) {} ends after a loop limitwkhtmltopdf 3/5 · headless Chromium 3/5
Languages
The whole alphabet is tested in system fonts, web fonts, bold and italic, and it survives text extraction from the PDF. Case mapping follows the language of the text, the kind of detail engines get wrong.
Ç ç Ğ ğ I ı İ i Ö ö Ş ş Ü ü
/* lang="tr" */
text-transform: uppercase;
istanbul → İSTANBUL
text-transform: capitalize;
izmir → İzmir
text-transform: lowercase;
IŞIK → ışık
Install
bdhtml2pdf builds from source with Rust 1.92 or newer and the fontconfig development files (fontconfig-devel on Fedora, libfontconfig1-dev on Debian and Ubuntu).
Until the upstream pull requests are merged, the build expects patched fulgur and Blitz next to it.
git clone https://github.com/bahadirdogru/bdhtml2pdf
git clone -b blitz-master https://github.com/bahadirdogru/fulgur
git clone -b public-layout-pass https://github.com/bahadirdogru/blitz
cd bdhtml2pdf
cargo build --release # target/release/bdhtml2pdf
The options follow wkhtmltopdf. The output extension picks the format: .pdf, .png, .jpg, or .html for the DOM after JavaScript ran.
bdhtml2pdf --page-size A4 --orientation Landscape \
--margin-top 15mm report.html report.pdf
# wait until the page sets window.status = "ready"
bdhtml2pdf --window-status ready --javascript-delay 2000 \
dashboard.html dashboard.pdf
# a 1280 px wide image of the whole page, at twice the pixels
bdhtml2pdf --width 1280 --zoom 2 page.html page.png
Status
Found by our own test suites. Details and plans are in the roadmap.
Intl in JavaScript; Turkish case mapping in CSS works