Convert HTML or any URL to pixel-perfect PDF — with native Thai font support, CSS3, flexbox, web fonts. Built for invoices, receipts, reports, and certificates.
🚀 Try live demo 📖 OpenAPI spec
preferThaiFont: true (default) and we auto-inject a proper Thai font stack.@page rules, SVG, canvas — everything works.Add your key in the X-Api-Key header. Demo key: demo-key-html-pdf (100 calls/day, no signup).
curl -X POST https://hubaiasia.com/html-pdf-api/pdf \
-H "X-Api-Key: demo-key-html-pdf" \
-H "Content-Type: application/json" \
-o receipt.pdf \
-d '{
"html": "<h1>ใบเสร็จรับเงิน</h1><p>ยอดรวม 1,500 บาท</p>",
"format": "A4",
"filename": "receipt.pdf"
}'
curl -X POST https://hubaiasia.com/html-pdf-api/pdf \
-H "X-Api-Key: demo-key-html-pdf" \
-H "Content-Type: application/json" \
-o report.pdf \
-d '{"url": "https://example.com/my-report"}'
{
"html": "<h1>Invoice #2026-042</h1>...",
"format": "A4",
"displayHeaderFooter": true,
"headerTemplate": "<div style='font-size:9px; width:100%; text-align:right; padding-right:15mm;'>บริษัท ABC จำกัด</div>",
"footerTemplate": "<div style='font-size:9px; width:100%; text-align:center;'>หน้า <span class='pageNumber'></span> / <span class='totalPages'></span></div>",
"margin": {"top": "25mm", "bottom": "25mm", "left": "15mm", "right": "15mm"}
}
| Param | Type | Default | Description |
|---|---|---|---|
html | string | — | Full HTML doc or fragment (auto-wrapped) |
url | string | — | Remote URL (use one of html/url) |
css | string | — | Extra CSS injected into <head> |
format | string | A4 | A4 | A3 | A5 | Letter | Legal | Tabloid |
landscape | bool | false | Orientation |
printBackground | bool | true | Render background colors/images |
margin | object | 20/15mm | {top, right, bottom, left} |
scale | number | 1 | 0.1 – 2.0 |
displayHeaderFooter | bool | false | Enable header/footer templates |
headerTemplate | string | — | HTML template (supports .pageNumber, .totalPages) |
footerTemplate | string | — | HTML template |
preferThaiFont | bool | true | Auto-inject Thai font stack |
output | string | binary | binary | base64 |
filename | string | document.pdf | Download filename |
Built by HubAI Asia · Chromium + Playwright · Thai fonts: Loma, Garuda, Noto Sans Thai