Documentation

AIVEXA PDF API converts HTML and URLs to PDF using headless Chromium. Full JavaScript support, custom fonts, CSS print styles, and all standard PDF options.

Overview

The AIVEXA PDF API is a REST API that accepts HTML markup or a publicly accessible URL and returns a professionally rendered PDF file. The rendering engine is based on Chromium, which means the output is identical to what you would see in a Chrome browser with Print to PDF.

Base URL: https://aivexa.com/api/v1

Quick Start

1. Sign up and create an API key in your dashboard.

2. Make a POST request:

curl -X POST https://aivexa.com/api/v1/pdf \
  -H "Authorization: Bearer avx_pdf_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Hello World</h1>", "format": "A4"}' \
  --output document.pdf

3. The response is a binary PDF. Save it directly to a file with --output.

Authentication

All API requests require an API key sent in the Authorization header:

Authorization: Bearer avx_pdf_live_YOUR_KEY
Key TypePrefixBehaviour
Liveavx_pdf_live_Consumes credits, production use
Testavx_pdf_test_Free, no credits consumed, for development

⚠️ Never expose API keys in browser JavaScript, public repositories, or client-side code.

HTML to PDF

POST /api/v1/pdf

ParameterTypeRequiredDescription
htmlstringYesFull HTML markup to convert
formatstringNoA3, A4, A5, A6, Letter, Legal, Tabloid. Default: A4
orientationstringNoportrait or landscape. Default: portrait
marginobjectNo{top, right, bottom, left} in mm. e.g. "10mm"
printBackgroundbooleanNoPrint background colors and images. Default: true
scalenumberNoContent scale 0.1–2.0. Default: 1
mediaTypestringNoprint or screen. Default: screen
displayHeaderFooterbooleanNoEnable header and footer
headerTemplatestringNoHTML for page header
footerTemplatestringNoHTML for page footer
waitForSelectorstringNoCSS selector to wait for before rendering
waitUntilstringNoload | domcontentloaded | networkidle0 | networkidle2
delaynumberNoDelay in ms before rendering (max 10000)
filenamestringNoPDF filename in Content-Disposition header

URL to PDF

POST /api/v1/url-to-pdf

Same options as HTML to PDF, but accepts a url parameter instead of html. The URL must be publicly accessible. Private IPs, localhost, and metadata endpoints are blocked.

{
  "url": "https://example.com/invoice/123",
  "format": "A4",
  "waitForSelector": "#invoice-loaded",
  "waitUntil": "networkidle0"
}

Screenshot

POST /api/v1/screenshot

ParameterTypeDescription
html / urlstringHTML markup or public URL (one required)
formatstringpng or jpeg. Default: png
fullPagebooleanCapture full scrollable page. Default: false
viewportWidthnumberViewport width in px. Default: 1280
viewportHeightnumberViewport height in px. Default: 800
qualitynumberJPEG quality 1–100. Default: 90

Headers & Footers

Set displayHeaderFooter: true and provide HTML templates. The following CSS classes are available:

ClassReplaced with
.dateFormatted print date
.titleDocument title
.urlPage URL
.pageNumberCurrent page number
.totalPagesTotal number of pages
"footerTemplate": "<div style='font-size:10px;text-align:center;width:100%'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>"

Errors

All errors return a JSON body with consistent structure:

{
  "error": {
    "code": "QUOTA_EXCEEDED",
    "message": "Monthly PDF quota exceeded. Upgrade your plan to continue.",
    "request_id": "req_01KXX..."
  }
}
CodeHTTPMeaning
MISSING_API_KEY401No Authorization header provided
INVALID_API_KEY401Key does not exist
API_KEY_REVOKED401Key was revoked
QUOTA_EXCEEDED429Monthly credit limit reached
RATE_LIMIT_EXCEEDED429Too many requests per minute
INVALID_HTML400HTML could not be rendered
INVALID_URL400URL is not valid HTTP/HTTPS
BLOCKED_URL400URL points to private address
HTML_TOO_LARGE400HTML exceeds 10 MB limit
RENDERING_TIMEOUT500Rendering exceeded time limit
BROWSER_ERROR500Unexpected browser error
INTERNAL_ERROR500Server-side error

Rate Limits

Rate limits are per API key, per minute:

PlanRequests/min
Free5
Starter20
Growth50
Pro150

Rate limit headers are included in every response:

X-RateLimit-Limit: 20
X-RateLimit-Remaining: 18
X-Request-ID: req_01KXX...