Still on wicked_pdf? I wrote a :pdf renderer that needs neither wkhtmltopdf nor headless Chrome
I'm the author. If you have a Rails app still on wicked_pdf, you've probably had the same conversation I did after wkhtmltopdf was archived in 2023: keep shipping an unmaintained binary, or move to Grover and take on a Chrome process.
I wrote a third option. sghtmltopdf is a rendering engine in Rust with no browser inside it — the HTML and CSS parsers come from Servo's crates, and the layout and pagination are written for this project. The gem registers a :pdf renderer in the spirit of wicked_pdf, so an existing controller often needs no changes:
render pdf: "invoice",
template: "invoices/show",
layout: "pdf",
page_size: "A4",
margin_top: "20mm"
show_as_html: true works too, so you can still open the thing in a browser and poke at it with devtools. The converter keys are flat CLI flag names, so wicked_pdf's nested margin: {top: 10} becomes margin_top: "10mm" — the docs map every key one by one.
A few things that matter inside a Rails process specifically. It runs in-process via a native extension, so no subprocess and no temp files, and it releases the GVL while rendering so other Puma threads keep working. /assets/... URLs resolve as local files, with helpers that inline assets in development. And with ActionController::Live you can stream pages as their layout finalizes, which also makes Rack::Timeout effective at chunk boundaries.
If you'd rather not spend app CPU on rendering, or the gem can't run where your app runs, set server_url and the same calls get delegated to a separate server process.
JavaScript execution isn't in yet and CSS coverage isn't complete — both are things I want to grow, and JS is likely to come via an embedded engine rather than a browser. Pixel parity with Chrome isn't a goal, though. Right now it handles invoices, receipts and reports well; for arbitrary pages it isn't the tool.
Early 0.1 release, MIT, precompiled gem.
Migration notes from wicked_pdf: https://waka.github.io/sghtmltopdf/migration/wicked-pdf.html
Repo: https://github.com/waka/sghtmltopdf
Sample output: