A pooled headless Chrome instance instead of an abandoned wkhtmltopdf binary — real CSS, real layout, real fonts, no separate renderer to compile or package.
Any controller action. The same view. A PDF instead of HTML. HtmlToPdf renders the exact view your app already has — the same ERB, the same CSS, the same layout — and converts it with real headless Chrome instead of wkhtmltopdf's years-out-of-date, unmaintained WebKit build. Flexbox, CSS Grid, and modern fonts render the way they actually look in a browser, because it is a browser.
gem install htmlToPdf
class ApplicationController < ActionController::Base
include HtmlToPdf
around_action :html_to_pdf
end
<%= link_to "Download PDF", invoice_path(@invoice, format: :pdf) %>
pdf_options[:layout]).around_action, not a before_action that quietly
re-runs your action on a throwaway controller — every other callback, instance variable, and
rescue_from works exactly like it does for an ordinary request.| Capability | HtmlToPdf | WickedPdf / PDFKit | Grover | Prawn |
|---|---|---|---|---|
| Renders your existing view | ✓ | ✓ | ✓ | — (own DSL) |
| Rendering engine | Chrome (current) | wkhtmltopdf (unmaintained) | Chrome via Puppeteer | n/a |
| Modern CSS (flexbox/Grid) | ✓ | — | ✓ | n/a |
| Extra runtime needed | Chrome/Chromium only | wkhtmltopdf binary | Chrome + Node.js + Puppeteer | none |
| Pooled browser (no per-request spawn) | ✓ | n/a | depends on setup | n/a |
around_action-safe callback ordering | ✓ | varies | varies | n/a |
Full breakdown in Choosing a Rails HTML-to-PDF gem.
around_action.