HTML to PDF API
Convert webpages and raw HTML to pixel-perfect PDF documents. A4, Letter, Legal formats. Custom margins. Print backgrounds.
Quick Start
# From a URL
curl -X POST https://batian.icu/api/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/report", "format": "A4"}' \
-o report.pdf
# From raw HTML
curl -X POST https://batian.icu/api/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "Invoice #42
Total: $500
", "format": "A4"}' \
-o invoice.pdf
Features
URL or Raw HTML
Pass a URL to convert an existing page, or send raw HTML for dynamic documents like invoices and receipts.
Multiple Page Formats
A4, Letter, Legal, Tabloid. Custom margins control top, right, bottom, left independently.
Print Backgrounds
Background colors and images render in the PDF โ unlike browser print-to-PDF which strips them by default.
No Headless Chrome Setup
We maintain the Chromium instances. You send JSON, you get a PDF. No Docker, no puppeteer.launch(), no chromium flags.
Use Cases
๐งพ Invoice Generation โ Render HTML invoices as PDFs. Send raw HTML with dynamic data, get back a professional PDF.
๐ Report Automation โ Convert analytics dashboards, weekly reports, or data summaries to PDF for email distribution.
๐ Contract & Legal Documents โ Generate terms of service, contracts, NDAs as PDFs from HTML templates with custom margins.
๐ซ Tickets & Certificates โ Create event tickets, course certificates, or reservation confirmations. HTML โ PDF in one API call.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
url | string | โ | URL to convert (use url OR html) |
html | string | โ | Raw HTML to convert (use url OR html) |
format | string | A4 | Page size: A4, Letter, Legal, Tabloid |
margin | string | 10mm | Page margin (CSS value like "10mm" or "0.5in") |
Start generating PDFs instantly
100 free PDF conversions every month. No credit card. Instant API key.
Get Free API Key