HTML to PDF API
POST /v1/pdf
Convert webpages or raw HTML content into high-quality PDF documents. Supports custom page sizes, orientations, margins, and headers/footers.
Endpoint
POST https://api.devutils.io/v1/pdfParameters
You must provide either url or html, but not both.
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Conditional | URL of the webpage to convert |
| html | string | Conditional | Raw HTML content to convert |
| pageSize | string | No | Page size: A4, Letter, Legal, Tabloid. Default: A4 |
| orientation | string | No | portrait or landscape. Default: portrait |
| margin | object | No | Page margins {top, right, bottom, left} in pixels or CSS units |
| printBackground | boolean | No | Include background graphics. Default: true |
Example Request
Convert URL to PDFbash
curl -X POST https://api.devutils.io/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"pageSize": "A4",
"orientation": "portrait",
"margin": {
"top": "20px",
"right": "20px",
"bottom": "20px",
"left": "20px"
}
}'Convert Raw HTML to PDFbash
curl -X POST https://api.devutils.io/v1/pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<html><body><h1>Hello World</h1><p>This is a test PDF.</p></body></html>",
"pageSize": "Letter"
}'Response
Success Responsejson
{
"success": true,
"data": {
"pdf_url": "https://cdn.devutils.io/pdfs/xyz789.pdf",
"pages": 3,
"size": "245KB"
}
}The pdf_url is valid for 24 hours. Download or store the PDF before expiration.