Runs on Cloudflare Workers + Browser Rendering

HTML to PDF API
Turn HTML or a URL into a PDF with one request

Send HTML or a URL and get a PDF back right away. Built for receipts, quotes, reports and dashboards, with full Thai text support.

cURL
curl -X POST https://YOUR_HOST/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Receipt</h1><p>Total paid: $15.00</p>","format":"A4"}' \
  --output invoice.pdf

Why us

Built for production

Pay only for what works

Quota is counted only after a PDF is created successfully. Invalid requests and failed renders are never counted.

We do not store your files

Your HTML and PDFs are never saved to our database. We keep only monthly usage counts, key hashes, Stripe payment reference IDs, and the email and IP address used when a free key is requested.

Thai text supported

Tested with the Sarabun font: Thai characters, vowels and tone marks render correctly in the PDF. We recommend including a Thai web font from Google Fonts in your HTML for consistent results.

API reference

API documentation

Authentication

Send your key in the Authorization: Bearer lk_... or x-api-key: lk_... header on every request.

POST /v1/pdf

Send JSON and receive a PDF (application/pdf) back. Set Content-Type: application/json.

ParameterTypeDefaultDescription
htmlstring-The HTML to convert. Send exactly one of html or url.
urlstring-An http(s) page that the browser opens and prints to PDF.
formatstringA4A0-A6, Letter, Legal, Tabloid, Ledger (case-insensitive)
landscapebooleanfalsetrue = landscape orientation
printBackgroundbooleantruePrint background colors and images
preferCSSPageSizebooleanfalseUse the page size from CSS @page
scalenumber10.1 to 2
marginobject-Set top, right, bottom, left as strings, e.g. "10mm"
pageRangesstring-e.g. "1-3"
headerTemplate, footerTemplatestring-HTML for the page header/footer (setting either one enables both)
waitUntilstringloadload, domcontentloaded or networkidle (30-second timeout)
viewportobject-Browser window size before printing, e.g. {"width":1280,"height":800} (200 to 3840 px). Useful for URLs whose layout depends on screen width.
cssstring-CSS injected into the page before printing (up to 100,000 characters), e.g. to turn off page animations.
emulateMediaTypestring-screen or print: the media type used while rendering.
waitForTimeoutnumber0Wait (milliseconds) after the page loads, 0 to 10000. For pages with animations.

Code examples

curl -X POST https://YOUR_HOST/v1/pdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Hello</h1>","format":"A4"}' \
  --output out.pdf

Response headers: x-leafkiln-used (files used this month) and x-leafkiln-limit (monthly quota)

GET /v1/usage

Shows the plan and quota for your key. Calls to this endpoint do not count as usage.

{ "plan": "free", "used": 2, "limit": 100, "remaining": 98 }

Error codes

HTTPcodeMeaning and fix
400bad_requestInvalid JSON or parameters. See error.message.
401unauthorizedMissing, invalid or revoked key.
402quota_exceededMonthly quota used up. It resets at the start of each month (UTC), or upgrade your plan.
413too_largeRequest body exceeds 6 MB.
422 / 502render_failedThe PDF could not be created. Check your HTML/URL and retry. Not counted against your quota.
503capacityRendering capacity is temporarily full. Wait a moment and retry.

Interactive sandbox

Try the API right here

Pricing

Monthly plans

Pay, then receive your API key instantly on the next page

Free

Free
  • 100 files/month
  • Every API parameter
Get a free key

Starter

$9 /month
  • 2,000 files/month
  • Only successful jobs counted
Subscribe and pay

Pro

$29 /month
  • 10,000 files/month
  • Only successful jobs counted
Subscribe and pay

Scale

$99 /month
  • 50,000 files/month
  • Only successful jobs counted
Subscribe and pay

Get started

Get a free key: 100 files/month

Your key is shown only once, so copy it somewhere safe. If you lose it, you can request a new one by email.