Convert HTML to PDF with cURL
Convert HTML to PDF from the command line using cURL. Perfect for quick testing, shell scripts, and automation.
Quick Start
curl -X POST https://html2pdfapi.com/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello World</h1>", "format": "pdf"}' \
--output output.pdfConvert URL to PDF
curl -X POST https://html2pdfapi.com/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"format": "pdf",
"options": {
"format": "A4",
"printBackground": true
}
}' \
--output webpage.pdfTake Screenshot
curl -X POST https://html2pdfapi.com/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"format": "png",
"options": {
"width": 1920,
"height": 1080
}
}' \
--output screenshot.pngRead HTML from File
# Read HTML from file
curl -X POST https://html2pdfapi.com/render \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"html\": $(cat template.html | jq -Rs .), \"format\": \"pdf\"}" \
--output output.pdfAvailable Options
| Option | Type | Description |
|---|---|---|
| format | string | Output format: 'pdf', 'png', 'jpeg', 'webp' |
| html | string | HTML content to convert |
| url | string | URL to convert |
| options.format | string | Page size: 'A4', 'Letter', etc. |
| options.landscape | boolean | Landscape orientation |
| options.printBackground | boolean | Include background colors/images |
Other Integrations
See Use Cases
Get Your API Key
Sign up and start converting HTML to PDF from the command line.