Convert any HTML to a pixel-perfect PDF in under 2 seconds via REST API.
HTML2DocHub provides a fast, reliable HTML to PDF API powered by Chromium. No server setup needed. Send HTML or a URL, get back a signed download URL. Pay only for what you use — starting at ₹0.10 per page. No monthly fees, no minimums.
curl -X POST https://api.html2dochub.com/v1/render \
-H "X-API-Key: sk_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "pdf",
"html": "<h1>Invoice #1042</h1><p>Amount: $299.00</p>",
"options": {
"format": "A4",
"print_background": true,
"margin_top": "2cm",
"margin_bottom": "2cm"
}
}'
# Response:
# {
# "job_id": "...",
# "status": "completed",
# "pages": 1,
# "cost": "₹0.10",
# "download_url": "https://cdn.html2dochub.com/..."
# }import requests
resp = requests.post(
"https://api.html2dochub.com/v1/render",
headers={"X-API-Key": "sk_live_YOUR_KEY"},
json={
"type": "pdf",
"html": open("invoice.html").read(),
"options": {"format": "A4", "print_background": True},
},
)
data = resp.json()
print(f"Pages: {data['output_pages']}, Cost: {data['final_cost']}")
# Download the PDF
import urllib.request
urllib.request.urlretrieve(data["download_url"], "invoice.pdf")const fs = require("fs");
const response = await fetch("https://api.html2dochub.com/v1/render", {
method: "POST",
headers: {
"X-API-Key": "sk_live_YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "pdf",
html: fs.readFileSync("invoice.html", "utf8"),
options: { format: "A4", print_background: true },
}),
});
const { download_url, final_cost } = await response.json();
console.log("Cost:", final_cost);
// Save to disk
const pdfResp = await fetch(download_url);
const buffer = await pdfResp.arrayBuffer();
fs.writeFileSync("invoice.pdf", Buffer.from(buffer));Pay only for pages rendered. No subscriptions. No minimum monthly fee.
Free account. No credit card required. API ready in minutes.
Get your free API key