PDF Generator

Convert HTML content to PDF documents. Perfect for invoices, reports, and certificates.

POST/v1/pdf/generate

Renders 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)

NameTypeRequiredDefaultDescription
htmlstringYes-The HTML content to convert to PDF.
page_sizestringNoA4Page size: A4, Letter, Legal, A3, or A5.
orientationstringNoportraitPage orientation: portrait or landscape.
margin_topstringNo20mmTop margin (e.g., 10mm, 0.5in).
margin_bottomstringNo20mmBottom margin.
margin_leftstringNo15mmLeft margin.
margin_rightstringNo15mmRight margin.
header_htmlstringNo-HTML for the page header.
footer_htmlstringNo-HTML for the page footer. Supports {{page}} and {{pages}} placeholders.
cssstringNo-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.pdf

Response

Returns the PDF as binary data with Content-Type: application/pdf.

Error Codes

StatusErrorDescription
400missing_htmlThe html field is required in the request body.
400invalid_page_sizeUnsupported page size. Use A4, Letter, Legal, A3, or A5.
401unauthorizedMissing or invalid API key.
413payload_too_largeHTML content exceeds the 5MB limit.
429rate_limit_exceededToo many requests.