PDF Generator
Convert HTML content to PDF documents. Perfect for invoices, reports, and certificates.
POST
/v1/pdf/generateRenders HTML content into a PDF document using a headless browser. Supports custom page sizes, margins, headers, footers, and CSS. Send your HTML as a string in the request body.
Authentication
Requires x-api-key header.
Request Body (JSON)
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| html | string | Yes | - | The HTML content to convert to PDF. |
| page_size | string | No | A4 | Page size: A4, Letter, Legal, A3, or A5. |
| orientation | string | No | portrait | Page orientation: portrait or landscape. |
| margin_top | string | No | 20mm | Top margin (e.g., 10mm, 0.5in). |
| margin_bottom | string | No | 20mm | Bottom margin. |
| margin_left | string | No | 15mm | Left margin. |
| margin_right | string | No | 15mm | Right margin. |
| header_html | string | No | - | HTML for the page header. |
| footer_html | string | No | - | HTML for the page footer. Supports {{page}} and {{pages}} placeholders. |
| css | string | No | - | Additional CSS to inject into the page. |
Example Request
-blue-400 font-semibold">curl -X POST -emerald--amber-400">400">"https://api.aicores.io/v1/pdf/generate" \
-H -emerald--amber-400">400">"x-api-key: sk_live_your_key_here" \
-H -emerald--amber-400">400">"Content-Type: application/json" \
-d -emerald--amber-400">400">'{
"html": "<h1>Invoice #-amber-400">1234</h1><p>Amount: $-amber-400">99.00</p><p>Due: March -amber-400">30, -amber-400">2026</p>",
"page_size": "A4",
"margin_top": "25mm",
"footer_html": "<div style="text-align:center;font-size:10px;">Page {{page}} of {{pages}}</div>"
}' \
--output invoice.pdfResponse
Returns the PDF as binary data with Content-Type: application/pdf.
Error Codes
| Status | Error | Description |
|---|---|---|
| 400 | missing_html | The html field is required in the request body. |
| 400 | invalid_page_size | Unsupported page size. Use A4, Letter, Legal, A3, or A5. |
| 401 | unauthorized | Missing or invalid API key. |
| 413 | payload_too_large | HTML content exceeds the 5MB limit. |
| 429 | rate_limit_exceeded | Too many requests. |