Replace Puppeteer with an HTML-to-PDF API

Last updated: . Every code sample on this page was run against the live API with the sandbox key on that date.

Short answer: If you only need HTML/CSS → PDF (invoices, reports, letters), replace page.pdf() with one POST https://rendlet.com/v1/pdf. You drop the Chromium binary from your image, skip --no-sandbox flags, and keep using the same HTML you already generate. Rendlet still renders with headless Chromium — just on its side.

When an API is a better fit than self-hosted Puppeteer

Self-hosted PuppeteerRendlet API
InstallChrome / Chromium in every container or CI runnerNothing: one HTTPS call
Cold start / memoryHundreds of MB for the browserYour function stays small
JavaScript in the pageRuns (if you wait for it)Not run (send finished HTML)
Login / cookies / live URLYesNo — send HTML you already have
OpsYou patch Chrome and handle crashesHard monthly caps, no overage billing

Full trade-offs: Rendlet vs self-hosted Puppeteer. Migrating off archived wkhtmltopdf: Rendlet vs wkhtmltopdf.

1. Try it with curl

The public sandbox key needs no signup (5 renders a day per network, 1 page, up to 50 KB, faint watermark).

# Works as-is with the public sandbox key. With your own key: export RENDLET_API_KEY=YOUR_API_KEY
curl -X POST https://rendlet.com/v1/pdf \
  -H "Authorization: Bearer ${RENDLET_API_KEY:-sandbox}" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Hello</h1><p>Rendered by Rendlet.</p>","options":{"format":"A4","margin":"15mm"}}' \
  -o hello.pdf

2. Side-by-side: Puppeteer → Rendlet

Before (you launch Chrome):

// Self-hosted Puppeteer (you install and run Chrome)
import puppeteer from "puppeteer";
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
const page = await browser.newPage();
await page.setContent("<h1>Hello</h1><p>Rendered locally.</p>", { waitUntil: "networkidle0" });
await page.pdf({ path: "hello.pdf", format: "A4", margin: { top: "15mm", bottom: "15mm", left: "15mm", right: "15mm" } });
await browser.close();

After (same PDF shape, no Chrome in your app). When we ran this against the live sandbox on 2026-11-07: saved hello.pdf; … renders left with X-Pages: 1 and a ~12 KB PDF.

// Same result via Rendlet (Node 18+, no Chrome in your app)
import { writeFile } from "node:fs/promises";

const res = await fetch("https://rendlet.com/v1/pdf", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RENDLET_API_KEY ?? "sandbox"}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    html: "<h1>Hello</h1><p>Rendered by Rendlet.</p>",
    options: { format: "A4", margin: "15mm" },
  }),
});
if (!res.ok) throw new Error(`Rendlet ${res.status}: ${await res.text()}`);
await writeFile("hello.pdf", Buffer.from(await res.arrayBuffer()));
console.log("saved hello.pdf;", res.headers.get("x-quota-remaining"), "renders left");

Map Puppeteer options roughly like this: format → options.format, CSS margins → options.margin, printBackground: true → options.printBackground, landscape: true → options.landscape. Build the HTML first (your template engine or a finished string); do not rely on client-side JS or a private URL.

When to keep Puppeteer

Keep a self-hosted browser if the page needs JavaScript to finish (charts, SPAs), a logged-in session, or you must print a live URL you don't control. In those cases Rendlet is the wrong tool — use Puppeteer/Playwright yourself, or fetch HTML first and then call the API.

3. Options

FieldValues
options.formatA4, Letter, Legal, A3, A5
options.landscapetrue / false
options.marginCSS length, e.g. "15mm" or "0"
options.printBackgroundtrue / false
filenameName used in the Content-Disposition header
response"binary" (default) or "base64": JSON {filename, pages, bytes, content_type, base64}

For HTML input, JavaScript in the page is not run, and only data: URIs and public https:// assets (images, fonts, CSS) load. Inline your CSS or link it over https. Simplified Chinese works out of the box (Noto Sans SC is bundled).

Errors and response headers

Successful renders return X-Pages, X-Plan, X-Quota-Limit and X-Quota-Remaining. Errors are JSON like {"error":"...","message":"..."}: 400 bad request, 401 missing key, 403 invalid key, 413 HTML too large or too many pages, 429 quota exceeded, 500 render failed.

Limits to know

SandboxFreeStarterProScale
Price$0$0$7/mo$19/mo$59/mo
Documents5 / day / network100 / month1,000 / month5,000 / month25,000 / month
Requests per minute3103060120
Pages per document11050200500
HTML size50 KB1 MB2 MB2 MB2 MB

Every plan has a hard monthly cap: at the cap the API returns 429 with an upgrade_url, and you are never billed for overage. Failed renders don't count. Source: docs.

Try it on your own HTML. The sandbox renders a real PDF with no signup (5 a day per network, 1 page, watermarked). A free key gives 100 documents a month, up to 10 pages each, with no watermark.

Open the sandbox →   Get a free key · Pricing

Related