wkhtmltopdf vs Chromium: Choosing the Right PDF Engine
"Should I stick with wkhtmltopdf, or migrate to Chromium?" is one of the most common questions developers ask when building PDF generation into their applications.
This article breaks down the differences with API call examples and use-case-specific workflows to help you make the right choice.
What is wkhtmltopdf?
wkhtmltopdf is an open-source HTML to PDF converter based on the QtWebKit engine. It has been used in many projects, but QtWebKit itself was deprecated in 2015 and removed from Qt in 2016 (see the official status page).
Strengths
- Simple: one command, no browser to manage
- Light: generally lighter than running a full Chromium browser (measure speed and memory with your own HTML)
- Track record: used in production for years
Limitations
- Don't expect newer CSS such as Grid (FUNBREW PDF's own docs list the fast engine as "CSS2.1 + partial CSS3")
- JavaScript is enabled by default, but it only waits 200 ms for scripts before rendering (
--javascript-delay) - Print stylesheets (
@media print) are not used by default (only with--print-media-type) - The GitHub repository is archived; the latest release is 0.12.6 from June 2020
What is Chromium-based PDF Generation?
Tools like Puppeteer, Playwright, and Gotenberg use Chromium (the open-source engine behind Google Chrome) to render HTML and produce PDFs. Playwright's PDF output works only in headless Chromium.
Strengths
- Modern CSS: Grid, Flexbox, CSS variables, calc() are rendered by the same engine as the browser
- JavaScript execution: scripts run, but Gotenberg "prints the page as soon as it loads", so animations and async rendering are not waited for
- Print CSS: the PDF is produced the same way as browser printing (Puppeteer's
page.pdf()renders with the print media type)
Limitations
- Needs a full browser (the Chrome for Testing build that Puppeteer downloads is about 282MB on Linux)
- Self-hosting means process management, memory management, and keeping the browser updated
Quality Comparison
CSS Support
<!-- CSS Grid does not lay out as expected on the fast (wkhtmltopdf) engine -->
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 16px;">
<div>Left column</div>
<div>Right column</div>
</div>
The engine table in FUNBREW PDF's public docs (/docs, "Rendering engine") says:
| Item | fast (wkhtmltopdf) | quality (Chromium / Gotenberg) |
|---|---|---|
| CSS | CSS2.1 + partial CSS3 | CSS3 / Flexbox / Grid |
| WebP / AVIF images | Not rendered | Rendered |
@media print |
Not used (FUNBREW does not pass --print-media-type) |
Rendered as browser printing |
Check individual CSS properties by rendering your actual HTML on both engines.
Image Format Support
JPEG, PNG and GIF work on both engines. In FUNBREW PDF, WebP and AVIF render only on the quality (Chromium) engine and are missing on fast (wkhtmltopdf).
<!-- Won't render on fast (wkhtmltopdf) — quality only -->
<img src="photo.webp" alt="Photo">
<!-- Works in both engines -->
<img src="photo.jpg" alt="Photo">
When passing HTML with WebP images through FUNBREW PDF, specify "engine": "quality" to ensure correct rendering.
Japanese / CJK Fonts
Both engines need CJK fonts installed in the runtime environment to render Japanese text. If you self-host, installing fonts is a prerequisite. FUNBREW PDF's quality engine is expected to have Noto Sans CJK JP, so specify font-family: "Noto Sans CJK JP", sans-serif; and check the output.
Speed
FUNBREW PDF's public docs give a rough guide of "0.5–2s" for fast and "1–3s" for quality. Actual times vary a lot with HTML size, images, and external resources, so measure both engines with your own templates.
When to Use Which
Use wkhtmltopdf (fast) when:
- Simple text/table PDFs (receipts, basic invoices)
- High volume (speed comes first)
- Low latency required (real-time generation)
Use Chromium (quality) when:
- Design-heavy documents (CSS Grid/Flexbox layouts)
- Charts or dynamic content (JavaScript rendering — turn animations off)
- URL-to-PDF conversion (capture a live web page)
- WebP / AVIF images
API Call Examples
Here's how to switch engines using the FUNBREW PDF API in common languages. The generation API responds with JSON; fetch the PDF from data.download_url with an API key that has the download scope.
cURL
# Fast engine (wkhtmltopdf)
curl -s -X POST https://pdf.funbrew.cloud/api/pdf/generate-from-html \
-H "Authorization: Bearer $FUNBREW_PDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Invoice</h1><p>Total: $100</p>",
"options": {
"engine": "fast",
"page-size": "A4"
}
}' > invoice.json
curl -s -H "Authorization: Bearer $FUNBREW_PDF_API_KEY" \
-o invoice.pdf "$(jq -r '.data.download_url' invoice.json)"
# Quality engine (Chromium) — when CSS Grid is needed (Pro plan or above)
curl -s -X POST https://pdf.funbrew.cloud/api/pdf/generate-from-html \
-H "Authorization: Bearer $FUNBREW_PDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<div style=\"display:grid;grid-template-columns:1fr 1fr\">...</div>",
"options": {
"engine": "quality",
"page-size": "A4"
}
}' > report.json
curl -s -H "Authorization: Bearer $FUNBREW_PDF_API_KEY" \
-o report.pdf "$(jq -r '.data.download_url' report.json)"
Python
import os
import httpx
FUNBREW_PDF_API_KEY = os.environ["FUNBREW_PDF_API_KEY"]
HEADERS = {"Authorization": f"Bearer {FUNBREW_PDF_API_KEY}"}
def generate_pdf(html: str, engine: str = "fast") -> bytes:
"""
engine: "fast" (wkhtmltopdf) or "quality" (Chromium)
"""
response = httpx.post(
"https://pdf.funbrew.cloud/api/pdf/generate-from-html",
headers=HEADERS,
json={
"html": html,
"options": {
"engine": engine,
"page-size": "A4",
},
},
timeout=60.0,
)
response.raise_for_status()
download_url = response.json()["data"]["download_url"]
pdf = httpx.get(download_url, headers=HEADERS, timeout=60.0)
pdf.raise_for_status()
return pdf.content
# Invoice: simple HTML → fast engine is sufficient
invoice_html = "<h1>Invoice</h1><table>...</table>"
pdf_bytes = generate_pdf(invoice_html, engine="fast")
with open("invoice.pdf", "wb") as f:
f.write(pdf_bytes)
# Report with CSS Grid → quality engine
report_html = """
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 24px;">
<div>Sales summary</div>
<div>Year over year</div>
</div>
"""
pdf_bytes = generate_pdf(report_html, engine="quality")
with open("report.pdf", "wb") as f:
f.write(pdf_bytes)
Node.js
// Node.js 18+ (built-in fetch)
const fs = require('fs');
const headers = { Authorization: `Bearer ${process.env.FUNBREW_PDF_API_KEY}` };
async function generatePdf(html, engine = 'fast') {
const response = await fetch('https://pdf.funbrew.cloud/api/pdf/generate-from-html', {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({
html,
options: {
engine, // 'fast' (wkhtmltopdf) or 'quality' (Chromium)
'page-size': 'A4',
},
}),
});
if (!response.ok) {
throw new Error(`PDF generation failed: ${response.status}`);
}
const { data } = await response.json();
const pdf = await fetch(data.download_url, { headers });
if (!pdf.ok) {
throw new Error(`PDF download failed: ${pdf.status}`);
}
return Buffer.from(await pdf.arrayBuffer());
}
async function main() {
// Receipt: simple HTML → fast
const receiptHtml = '<h1>Receipt</h1><p>$50.00</p>';
fs.writeFileSync('receipt.pdf', await generatePdf(receiptHtml, 'fast'));
// Monthly report: Chart.js → quality
// quality prints as soon as the page loads, so turn animation off to draw synchronously
const reportHtml = `
<html>
<head><script src="https://cdn.jsdelivr.net/npm/chart.js"></script></head>
<body>
<h1>Monthly Report</h1>
<canvas id="salesChart" width="400" height="200"></canvas>
<script>
new Chart(document.getElementById('salesChart'), {
type: 'bar',
data: { labels: ['Jan','Feb','Mar'], datasets: [{ data: [65,59,80] }] },
options: { animation: false }
});
</script>
</body>
</html>
`;
fs.writeFileSync('report.pdf', await generatePdf(reportHtml, 'quality'));
}
main();
FUNBREW PDF's options have no key for a render delay. Set animation: false on charts, or render charts to images on the server and embed them.
Use-Case Workflows
Invoice Generation (wkhtmltopdf / fast)
Invoices are typically text and tables — wkhtmltopdf often delivers sufficient quality.
Order confirmed event
↓
Build invoice data as JSON
↓
generate_pdf(html, engine="fast")
↓
Upload to S3 + send email attachment
See automate invoice PDF generation for a full implementation example, and invoice automation use cases for real-world patterns.
Monthly Report (Chromium / quality)
When charts are drawn with JavaScript, Chromium — which runs JavaScript and modern CSS — is the better fit.
End-of-month batch job
↓
Aggregate data → build chart HTML (Chart.js etc., animation: false)
↓
generate_pdf(html, engine="quality") ← quality over speed
↓
Save to dashboard + distribute to managers
See report automation use cases for real examples with charts.
Certificate / Diploma (Chromium / quality)
Certificates with decorative fonts and complex layouts are a good fit for Chromium.
Completion event (exam passed, training finished, etc.)
↓
Inject student name + completion date into template
↓
generate_pdf(html, engine="quality") ← Flexbox layout supported
↓
Email PDF to recipient + save to user profile
See certificate automation use cases for implementation patterns.
High-Volume Batch Generation (wkhtmltopdf / fast)
For thousands of documents (monthly statements, bulk delivery notifications), throughput matters most. The API has a per-minute limit per plan and returns 429 with Retry-After when you exceed it, so cap concurrency and wait before retrying.
import asyncio
import os
import httpx
API_KEY = os.environ["FUNBREW_PDF_API_KEY"]
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
def build_html(record: dict) -> str:
return f"<h1>Statement</h1><p>Dear {record['name']}</p>"
async def generate_one(client: httpx.AsyncClient, sem: asyncio.Semaphore, record: dict) -> bytes:
async with sem:
while True:
response = await client.post(
"https://pdf.funbrew.cloud/api/pdf/generate-from-html",
headers=HEADERS,
json={"html": build_html(record), "options": {"engine": "fast"}},
timeout=60.0,
)
if response.status_code == 429:
await asyncio.sleep(int(response.headers.get("Retry-After", "60")))
continue
response.raise_for_status()
break
pdf = await client.get(response.json()["data"]["download_url"], headers=HEADERS, timeout=60.0)
pdf.raise_for_status()
return pdf.content
async def batch_generate(records: list[dict]) -> list[bytes]:
"""Parallel generation with capped concurrency (fast engine)"""
sem = asyncio.Semaphore(5)
async with httpx.AsyncClient() as client:
return await asyncio.gather(*(generate_one(client, sem, r) for r in records))
On every plan (including Free), POST /api/pdf/batch also accepts up to 100 items in one request.
Dual Engine with FUNBREW PDF
FUNBREW PDF lets you choose the engine per API request:
{
"html": "<h1>Hello</h1>",
"options": {
"engine": "fast"
}
}
| Parameter | Engine | Best for |
|---|---|---|
"engine": "fast" |
wkhtmltopdf | Speed, simple HTML |
"engine": "quality" |
Chromium/Gotenberg | Quality, modern CSS |
If you omit engine, plans that include quality (Pro and above) use the account's default engine if one is set, otherwise quality. The Free plan uses fast.
Switch engines with a single parameter — same template, different output quality.
Engine Availability by Plan
| Plan | Fast (wkhtmltopdf) | Quality (Chromium) |
|---|---|---|
| Free | Available | Playground only |
| Pro / Business | Available | Available |
On Free, requesting "engine": "quality" through the API returns 403.
Migration Cost Reality: wkhtmltopdf to Chromium
Understanding the actual migration cost is essential before switching engines.
Key Migration Challenges
1. Infrastructure changes
wkhtmltopdf runs as a single binary. Chromium via Puppeteer/Playwright requires a runtime such as Node.js plus the browser itself (the Chrome for Testing build Puppeteer downloads is about 282MB on Linux). Docker images get bigger and browser startup takes time.
# wkhtmltopdf-based Docker image
FROM surnet/alpine-wkhtmltopdf:3.24.3-0.12.6-full
# Node.js image with Chromium (Debian package)
FROM node:22-slim
RUN apt-get update && apt-get install -y chromium && rm -rf /var/lib/apt/lists/*
2. Operational complexity
Chromium requires sandbox configuration, memory management, and process monitoring. The PDF API production guide covers Chromium-specific considerations in detail, including --no-sandbox configuration and concurrency limits.
3. Update cadence
Chrome has shipped a new stable version every four weeks since Chrome 94, so self-hosting Chromium means keeping up with those updates. wkhtmltopdf, on the other hand, has had no release since 0.12.6 in June 2020 and its repository is archived — less update work, but no fixes either. The official status page warns not to use wkhtmltopdf with untrusted HTML.
To avoid this complexity, a managed PDF API service is a rational alternative. See Puppeteer to FUNBREW PDF migration for how to replace self-hosted Chromium with an API call.
Engine-Specific Troubleshooting
Common Problems and Fixes
Problem 1: Japanese/CJK characters are garbled in wkhtmltopdf
If no Japanese font is installed in the runtime environment, Japanese text won't render correctly. If the HTML doesn't declare its charset, also set the input encoding.
# Install CJK fonts on Debian / Ubuntu
apt-get install fonts-noto-cjk
# Set the input HTML encoding (this does not choose a font)
wkhtmltopdf --encoding utf-8 input.html output.pdf
See the Japanese PDF font guide for full setup details. Chromium can't render Japanese either when no Japanese font is installed.
Problem 2: CSS Grid layouts break in wkhtmltopdf
Newer layouts such as CSS Grid don't render as expected in wkhtmltopdf. Use the table-based workaround:
/* Does not lay out as expected in wkhtmltopdf (for Chromium) */
.report-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}
/* Compatible with wkhtmltopdf */
.report-table { width: 100%; table-layout: fixed; }
.report-cell { width: 33.3%; vertical-align: top; padding: 12px; }
More workarounds in the HTML to PDF CSS optimization guide.
Problem 3: Page breaks are wrong in Chromium
.section { page-break-before: always; /* or break-before: page; */ }
.no-break { page-break-inside: avoid; }
See PDF output troubleshooting for a systematic approach to diagnosing page break issues.
Engine Status in 2026
wkhtmltopdf Maintenance Status
The wkhtmltopdf GitHub repository is archived (read-only), and the latest release is 0.12.6 from June 2020. Its QtWebKit base was deprecated in 2015 and removed from Qt in 2016, so don't expect support for newer CSS or image formats.
We do not recommend adopting wkhtmltopdf for new projects. For existing systems, continued use is acceptable, but plan to migrate when adding features that require modern CSS.
Chromium / Puppeteer Trends
Since v20.0.0, Puppeteer downloads and works with Chrome for Testing instead of Chromium. Each Puppeteer version maps to a specific Chrome version, so pinning Puppeteer also pins the Chrome used for rendering. To use a Chrome you installed separately, pass executablePath.
// Use a Chrome for Testing build you installed yourself
const browser = await puppeteer.launch({
executablePath: '/path/to/chrome-for-testing',
args: ['--no-sandbox', '--disable-dev-shm-usage'],
});
Managed API as a Third Option
Rather than operating wkhtmltopdf or Chromium yourself, a managed API like FUNBREW PDF means you don't install or run the engines. The "engine" parameter switches between fast (wkhtmltopdf) and quality (Chromium) without any infrastructure changes. Pricing is a monthly fee per plan, with limits on monthly generations and requests per minute.
For a cost comparison between self-hosted and managed, see PDF API pricing comparison.
Error Handling Differences
When self-hosting, wkhtmltopdf reports errors through its exit code and output, while Puppeteer and similar tools use exceptions and events. Through the FUNBREW PDF API, both engines report errors as HTTP status codes. See the PDF API error handling guide for retry strategies.
| Status | Typical cause | What to do |
|---|---|---|
403 |
Requested quality on a plan without it |
Use fast or upgrade |
422 |
Validation error (e.g. a page-size value) |
Fix per the response message |
429 |
Exceeded the per-minute request limit | Wait Retry-After seconds and retry |
Summary
- Speed-first, simple HTML → wkhtmltopdf (
fast) - Quality-first, modern CSS → Chromium (
quality) - Want both → FUNBREW PDF's dual engine approach
- New projects → Avoid wkhtmltopdf; use Chromium or a managed API
Start with fast and switch to quality if rendering breaks. That's the most pragmatic approach.
Related
- HTML to PDF API Comparison 2026 — Compare pricing, features across services
- Puppeteer to PDF API Migration — Cut Chromium operational overhead
- PDF API Quickstart — Node.js, Python, and PHP code examples
- PDF Template Engine Guide — Efficient PDF generation with templates
- PDF API Production Guide — Chromium production configuration
- PDF API Error Handling — API error patterns
- HTML to PDF CSS Tips — CSS settings for both engines
- PDF API Pricing Comparison — Self-hosted vs managed cost analysis
- Invoice Automation Use Case — Invoice generation patterns
- Report Automation Use Case — Charts and report generation examples
- Certificate Automation Use Case — Automated certificate issuance
- Playground — Try the quality engine in your browser (with a TEST watermark)