Skip to main content
POST /convert/html-to-pdf supports three practical workflows:
  • Send inline HTML as JSON
  • Upload an HTML file as multipart form data
  • Render a public URL and capture the result as PDF

When To Use Each Mode

ModeBest forContent type
Inline HTMLServer-rendered templates, receipts, invoices, reportsapplication/json
HTML file uploadExisting .html assets on diskmultipart/form-data
URL modePublic pages you want to render remotelyapplication/json

JSON Contract

{
  "html": "<!doctype html><html><body><h1>Report</h1></body></html>",
  "url": null,
  "options": {
    "format": "A4",
    "landscape": false,
    "marginTop": "1cm",
    "marginBottom": "1cm",
    "marginLeft": "1cm",
    "marginRight": "1cm",
    "printBackground": true,
    "scale": 1,
    "waitForSelector": ".ready",
    "waitTimeout": 10000
  }
}
Use either html or url, never both in the same request.

Important Limits

  • Authenticated HTML payloads and HTML uploads are limited to 10 MB
  • URL mode only accepts public http and https addresses
  • Private or internal URLs are blocked
  • waitTimeout cannot exceed 30000 ms
  • Credit cost is 1 for inline HTML or file upload, 2 for URL mode

Common PDF Options

FieldMeaning
formatPaper size such as A4 or Letter
landscapeHorizontal page layout
printBackgroundInclude CSS backgrounds and colors
scalePage scale multiplier
waitForSelectorWait until a selector exists before rendering
waitTimeoutMaximum wait time in milliseconds

Multipart Upload Shape

When uploading an HTML file, send:
  • file: the HTML file
  • options: optional JSON string with the same PdfOptions object
Example:
curl --request POST \
  --url https://api.iyzpdf.com/v1/convert/html-to-pdf \
  --header "X-API-Key: $IYZPDF_API_KEY" \
  --form "file=@invoice.html" \
  --form 'options={"format":"A4","printBackground":true}' \
  --output invoice.pdf