Skip to main content
POST
https://api.iyzpdf.com/v1
/
convert
/
html-to-pdf
curl
curl --request POST \
  --url https://api.iyzpdf.com/v1/convert/html-to-pdf \
  --header "X-API-Key: $IYZPDF_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "html": "<!doctype html><html><body><h1>Invoice #1042</h1><p>Total: $99.00</p></body></html>",
    "options": {
      "format": "A4",
      "marginTop": "2cm",
      "marginBottom": "2cm",
      "printBackground": true
    }
  }' \
  --output invoice.pdf
{
  "fileName": "output.pdf",
  "size": 183240,
  "creditsUsed": 1,
  "creditsRemaining": 49,
  "contentType": "application/pdf"
}

Notes

  • Credits: 1 for inline HTML or file upload, 2 for URL mode
  • Use either html or url, never both
  • URL mode only supports public http and https addresses
  • Private or internal URLs are rejected
  • Authenticated HTML payloads and HTML uploads are limited to 10 MB

Authorizations

X-API-Key
string
header
required

Send your server-side API key in the X-API-Key header.

Body

html
string | null
url
string<uri> | null
options
object
Example:
{
"format": "A4",
"marginTop": "2cm",
"marginBottom": "2cm",
"printBackground": true
}

Response

Successful response. Send Accept: application/json to receive file metadata instead of the binary payload.

fileName
string
required
size
integer<int32>
required
creditsUsed
integer<int32>
required
contentType
string
required
creditsRemaining
integer<int32> | null