DEV Community

Dan E
Dan E

Posted on • Originally published at rendex.dev

Best HTML-to-PDF Tools in 2026 (APIs + Libraries)

Best HTML-to-PDF Tools in 2026 (APIs + Libraries)

Every production web app eventually needs HTML-to-PDF. The options range from zero-setup APIs to self-hosted headless browsers, and picking the wrong one means either managing Chromium memory leaks in production or paying per-call rates that don't fit your volume.

This roundup covers five tools against consistent criteria: CSS and JavaScript rendering quality, integration time, pricing model, and honest weaknesses. Five tools covered: Rendex, DocRaptor, PDFShift, wkhtmltopdf, and Playwright.

How These Tools Were Evaluated

  • CSS rendering: flexbox, grid, CSS custom properties, @media print support
  • JavaScript execution: waits for dynamic content, React/Vue/Svelte app rendering
  • Integration time: minutes from sign-up to first PDF
  • Pricing: free tier, per-call cost at 10k/month, overage handling
  • Infrastructure burden: managed API vs. you own the servers

1. Rendex API

Rendex runs Chromium on Cloudflare's global edge network. You POST a URL or raw HTML, get back a PDF. No browser to install, no memory to manage, no cold starts from a containerized Chrome.

# Replace rdx_live_YOUR_KEY with a key from https://rendex.dev/login
curl -X POST https://api.rendex.dev/v1/screenshot \
  -H "Authorization: Bearer rdx_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "pdf",
    "pdfFormat": "A4",
    "pdfMargin": "20mm",
    "pdfPrintBackground": true
  }' --output output.pdf
Enter fullscreen mode Exit fullscreen mode

HTML-to-PDF works the same way. Swap the url field for an html field with your template string. Useful for invoice generation where the page never needs to exist at a public URL.

curl -X POST https://api.rendex.dev/v1/screenshot \
  -H "Authorization: Bearer rdx_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Invoice #1042</h1><p>Amount due: $250</p>",
    "format": "pdf",
    "pdfFormat": "Letter",
    "pdfPrintBackground": true
  }' --output invoice.pdf
Enter fullscreen mode Exit fullscreen mode

The API reference covers page size options (A4, Letter, Legal, Tabloid), landscape mode, margin control, and scale. Python and JavaScript SDKs are available for both sync and async workflows.

For a deeper Python walkthrough, see How to Generate PDFs from URLs in Python.

Strengths: Full Chromium rendering, no infrastructure to run, global edge delivery, async batch jobs for high-volume workloads, geo-targeting on Pro plans.

Weaknesses: Monthly call caps per plan. If you need truly unlimited volume at predictable cost, the pricing model may not fit. The free tier gives you 500 calls/month to test before committing.

Pricing: Free tier (500 calls/month). Paid plans available at rendex.dev/pricing.

2. DocRaptor

DocRaptor uses the Prince XML rendering engine, which has been the reference implementation for the CSS Paged Media specification for over a decade. It handles complex print layouts, running headers and footers, page numbering, and advanced typographic features that Chromium-based tools handle inconsistently.

The trade-off is cost. DocRaptor is priced for document-heavy enterprise workflows, not high-volume automated generation. It excels at reports that need precise pagination control and legal or publishing workflows where print CSS compliance matters more than price per call.

Strengths: Best-in-class CSS Paged Media support, predictable print layout, long track record in publishing and legal tech.

Weaknesses: Expensive at scale. Not ideal for consumer-facing workflows with high call volumes. Fewer options for JavaScript-heavy SPAs compared to Chromium-based tools.

Best for: Legal documents, publishing pipelines, reports where pagination precision outweighs cost.

3. PDFShift

PDFShift is a hosted HTML-to-PDF API backed by a headless Chromium instance. The integration surface is minimal: one endpoint, one JSON body with source, landscape, margin, and a handful of other options.

PDFShift offers an EU-hosted option for teams with data residency requirements, which DocRaptor and some other APIs do not. Pricing is credit-based, which can be more cost-effective than per-call pricing if your usage is bursty.

Strengths: Simple API, EU data residency option, credit-based pricing suits variable workloads, good JavaScript support.

Weaknesses: Less established ecosystem than Puppeteer or DocRaptor. Credit expiration on some plans can be a surprise. Fewer geographic edge locations than Cloudflare-backed options.

Best for: Teams that need EU hosting, developers who want a simpler API surface than a full-featured rendering platform.

4. wkhtmltopdf

wkhtmltopdf is a command-line tool that converts HTML to PDF using a patched version of the QtWebKit engine. It requires no API call, works offline, and ships as a single binary in most Linux package managers.

# Install: apt install wkhtmltopdf
# Convert URL to PDF
wkhtmltopdf \
  --page-size A4 \
  --margin-top 20mm --margin-bottom 20mm \
  --margin-left 20mm --margin-right 20mm \
  --print-media-type \
  https://example.com output.pdf
Enter fullscreen mode Exit fullscreen mode

The problem is the engine. QtWebKit is effectively frozen at a 2012-era rendering baseline. Flexbox works partially, CSS Grid does not, and CSS custom properties are not supported. The project has been unmaintained since 2020. Modern web apps built with React, Vue, or Tailwind will render incorrectly or not at all.

Strengths: No API key required, no internet connection needed, fast for simple pages, available on every Linux distribution.

Weaknesses: Outdated WebKit engine, no CSS Grid or custom property support, limited JavaScript execution, effectively unmaintained. Not usable for modern SPAs.

Best for: Simple static HTML pages on isolated servers, legacy systems where adding an API call is not an option. Avoid for anything built in the last five years.

5. Playwright (Self-Hosted Chromium)

Playwright gives you a full Chromium browser under programmatic control. PDF generation uses the same print engine as Chrome's built-in Save as PDF, which means you get accurate rendering for any modern CSS layout. You can authenticate, dismiss banners, wait for specific elements, and inject CSS before capture.

// npm install playwright
// npx playwright install chromium
const { chromium } = require("playwright");

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto("https://example.com", { waitUntil: "networkidle" });
  await page.pdf({
    path: "output.pdf",
    format: "A4",
    margin: { top: "20mm", bottom: "20mm", left: "20mm", right: "20mm" },
    printBackground: true,
  });
  await browser.close();
})();
Enter fullscreen mode Exit fullscreen mode

The cost is infrastructure. Chromium uses ~300MB of RAM per browser instance. In a containerized environment with concurrent requests, you need to manage a browser pool, handle process crashes, and size your instances for peak load. On serverless platforms, Chromium requires special handling or a layer, and cold starts can add significant latency.

Strengths: Full modern CSS support, browser interaction before capture (logins, cookie banners, dynamic content), no per-call cost once running.

Weaknesses: Heavy infrastructure cost. Memory leaks in long-running processes are a real problem. Not practical on serverless without workarounds. You own the uptime, scaling, and maintenance.

Best for: Teams that already run their own server infrastructure, workflows requiring browser interaction before PDF generation, high-volume scenarios where per-call API pricing becomes prohibitive.

Comparison

Tool Engine CSS Grid Hosted Free Tier Best For
Rendex Chromium Yes Yes (CF edge) 500/mo APIs, agents, batch jobs
DocRaptor Prince XML Yes Yes Trial only Legal, publishing, print CSS
PDFShift Chromium Yes Yes (EU option) Trial credits EU data residency
wkhtmltopdf QtWebKit No No (CLI) Free/open source Simple legacy pages
Playwright Chromium Yes No (self-host) Free/open source Self-hosted, browser interaction

Which to Pick

You need a PDF in under an hour with working CSS: Rendex or PDFShift. Both are Chromium-backed APIs with free trials. Rendex includes batch jobs and MCP support for agent pipelines if that matters to your workflow.

You need complex print layouts: DocRaptor. Prince XML's CSS Paged Media support is the best available. You'll pay for it, but the output quality for complex multi-page documents is not matched by Chromium-based tools.

You have a data residency requirement (EU): PDFShift offers EU-hosted infrastructure. Verify their current data processing agreement before committing.

You run your own servers and need browser interaction: Playwright. Use it when the page requires authentication or dynamic interaction before PDF generation, and when you already have the infrastructure to run it.

You have simple static pages and no API budget: wkhtmltopdf gets the job done on pages from 2015. If the page uses Tailwind, React, or any modern CSS, expect problems.

See the URL-to-PDF use case page for a detailed breakdown of Rendex capabilities and integration patterns.

Next Steps

The fastest way to test any of the API options is the free URL-to-PDF tool: paste a URL, get a PDF back, no sign-up required. It uses the same Rendex rendering pipeline as the API.

Ready to automate? Get a free API key (500 calls/month, no credit card) and convert your first URL to PDF in under five minutes.

Top comments (0)