Processing...
Developer

HTML to PDF API Alternatives — Puppeteer, iText & When to Use RatPDF

Compare HTML to PDF APIs: Puppeteer, wkhtmltopdf, Gotenberg, SaaS renderers, and browser tools. CSS pitfalls and decision tree for developers.

Published July 2, 2025 · 1 min read

Teams pick an HTML to PDF API when invoices, tickets, or reports must render server-side — but the market spans headless Chrome, legacy WebKit wrappers, and hosted SaaS. This guide compares common approaches and when RatPDF's browser HTML to PDF tool fits (no deploy, no API key).

HTML to PDF API alternatives compared

ApproachBest forTrade-offs
Puppeteer / PlaywrightFull CSS3, SPAs after renderOps overhead — Chrome in Docker, memory per job
wkhtmltopdfLegacy templates, simple HTMLStale WebKit; flexbox gaps; maintenance mode
iText html2pdf / OpenPDFJava/.NET server PDF stacksNo JS execution; inline CSS works best
GotenbergSelf-hosted API wrapping ChromiumYou run and scale the container fleet
DocRaptor / PDFShift / similar SaaSManaged API, SLA, PrinceXML optionPer-document cost; data leaves your VPC
Browser print → PDFOne-off exportsNot automatable; margins inconsistent
RatPDF HTML to PDFAd-hoc templates, QA renders, small batchesNot a REST API — browser upload; 3 free uses/day

Decision tree

  1. Need JavaScript to run? → Puppeteer, Playwright, or Gotenberg — not static html2pdf alone.
  2. 100% self-contained HTML + CSS? → iText html2pdf (RatPDF uses this) or wkhtmltopdf for simple layouts.
  3. Don't want to operate Chrome? → Hosted API (DocRaptor, PDFShift) or RatPDF for manual batches.
  4. Unicode invoices (₹, €, CJK)? → Embed fonts in HTML; test with same engine as production.

CSS and font pitfalls (all engines)

  • Use @page { size: A4; margin: 20mm; } for print margins — not body padding alone
  • Prefer inline or embedded CSS; relative url(font.woff2) paths break on server render
  • Test with production HTML snapshot — not live SPA URLs that need auth cookies
  • Page breaks: page-break-before: always on section headers

Original example: invoice template QA

Startup renders GST invoice HTML from their Node app via Puppeteer in production. Designer updates CSS — staging API queue is backed up. Developer pastes static HTML into RatPDF HTML to PDF, verifies table alignment and ₹ symbol in 30 seconds, then promotes CSS to Puppeteer template. Production API unchanged; RatPDF used as visual regression shortcut.

When RatPDF is enough vs when you need an API

ScenarioRatPDF toolSelf-hosted API
Monthly manual report exportYesOverkill
1000 tickets/hour from queueNoYes — Puppeteer/Gotenberg
CI snapshot test of one templateYesOptional
Customer-facing SLA + retry logicNoYes — hosted or own fleet

Related resources

Try HTML to PDF →

Sources & references

Primary references used when researching and fact-checking this guide. See our editorial methodology.

  1. — iText Group
    HTML/CSS to PDF conversion engine used in server-side Java and .NET stacks.
  2. — Adobe
    PDF password protection and encryption standards (ISO 32000).