HTML to PDF
Render HTML content to a PDF document
POST
1 credit
/v1/convert/html-to-pdf
curl -X POST "https://convert.toolkitapi.io/v1/convert/html-to-pdf" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice #42</h1><p>Thanks for your business.</p>", "page_size": "A4"}'
import httpx
resp = httpx.post(
"https://convert.toolkitapi.io/v1/convert/html-to-pdf",
json={"html": "<h1>Invoice #42</h1><p>Thanks for your business.</p>", "page_size": "A4"},
)
print(resp.json())
const resp = await fetch("https://convert.toolkitapi.io/v1/convert/html-to-pdf", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({"html": "<h1>Invoice #42</h1><p>Thanks for your business.</p>", "page_size": "A4"}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response
200 OK
{
"pdf": "<base64-pdf>",
"page_count": 1,
"file_size": 21408,
"file_url": null,
"file_name": "output.pdf",
"file_type": "application/pdf"
}
Description
Render HTML content to a PDF document
How to Use
1
1. POST a JSON body containing the required `html` field.
2
2. Supply the optional parameters to fine-tune output.
3
3. When object storage is enabled, read `file_url` for a direct download; otherwise decode the Base64 `pdf` payload.
4
4. Inspect `page_count` (or equivalent) to confirm the full document was processed.
About This Tool
Convert inline HTML (with CSS) into a PDF using a headless browser. Ideal for invoices, certificates, receipts, and any server-generated template.
Supports external images, webfonts, and modern CSS including grid and flex layouts.
Why Use This Tool
- Invoices & receipts — Generate paginated PDF invoices from HTML templates
- Certificates — Produce printable certificates of completion
- Reports — Render a dashboard snapshot as a shareable PDF
- Tickets — Create QR-code tickets from event HTML
Frequently Asked Questions
Can I load external CSS and images?
Yes — absolute URLs to CSS, fonts and images are fetched at render time. Keep resources publicly accessible.
What page sizes are supported?
A3, A4, A5, Letter and Legal. Default is A4.
How are page breaks controlled?
Use standard CSS `break-before`, `break-after` and `break-inside` properties to guide pagination.
Start using HTML to PDF now
Get your free API key and make your first request in under a minute.