PDF Generation API
Headless Chromium
URL or HTML
SSRF-Safe

HTML or URL. Pixel-perfect PDF.

Render invoices, reports, and receipts from a live URL or a sanitized HTML string with headless Chromium. Choose page format, margins, orientation, and headers.

4 · page formats2 · render sources512k · max HTML charsbinary + base64 · output

Render a PDF live.

This calls the real PDF Generation API. Edit the HTML or pick a sample URL, then render an actual PDF right in the page.

Request builder
Rate-limited to 10/15min, so this one is click-to-run.
POST /from-html

Demo capped at 4,000 characters. The API accepts up to 512,000.

Output preview
Live response from the API, plus the exact request to reproduce it.

Run the request to render a live PDF preview here.

Why PDF Generation API

Documents without a print pipeline.

Two render sources

Render from a live public URL or from a sanitized HTML string up to 512,000 characters, both through headless Chromium.

Page format and margins

Choose A4, Letter, Legal, or Tabloid, and set per-side margins in mm, cm, in, or px for print-ready output.

Layout options

Landscape orientation, page ranges, and Chromium header/footer templates with page numbers and titles.

Render-wait control

Set waitUntil navigation strategy and wait for a CSS selector before capture, so dynamic content is fully painted first.

Binary or base64

Return raw application/pdf bytes for direct downloads, or a base64 JSON payload with byte length and render timing metadata.

SSRF-safe rendering

URL targets pass SSRF guards on the entry URL and redirects, and HTML is sanitized before rendering.

/api/v1/pdf-generation

Endpoints, at a glance.

Two POST render endpoints share the same options. POST is required for large HTML payloads and structured rendering settings.
POST/api/v1/pdf-generation/from-url

Render from URL

Render a PDF from a validated public URL. SSRF-guarded on the entry URL and redirects.

PRIMARY
POST/api/v1/pdf-generation/from-html

Render from HTML

Render a PDF from a sanitized HTML string, up to 512,000 characters.

GET/health

Service health

Status, service name, version, and timestamp.

GET/metrics

Prometheus metrics

Includes pdf_generation_operations_total and latency histograms.

ParameterTypeRequiredDescription
urlstringfrom-urlPublic http or https URL to render.
htmlstringfrom-htmlHTML string to render, max 512,000 characters. Sanitized.
formatstringnoPage format: A4 (default), Letter, Legal, or Tabloid.
marginsobjectnoOptional { top, right, bottom, left }, each matching a mm/cm/in/px value.
waitUntilstringnoURL navigation wait: load, domcontentloaded, networkidle0, networkidle2 (default).
options.landscapebooleannoLandscape orientation. Default false.
options.pageRangesstringnoPage ranges to output, e.g. 1-2,4.
options.displayHeaderFooterbooleannoEnable Chromium header/footer with headerTemplate and footerTemplate.
renderWait.waitForSelectorstringnoCSS selector to wait for before capture, with waitForSelectorTimeoutMs (100-30000).
responseTypestringnobinary (default) for raw PDF bytes, or base64 for a JSON payload.

Error reference

Built for heavy rendering.

Rendering is resource-intensive, so failures are explicit. Every error carries a correlationId to help you decide between retrying and backing off.

400Validation / Blocked URL

Invalid request body, or the URL is blocked by the SSRF guard on the entry URL or a redirect target.

401Authentication Error

Missing or invalid gateway API key. Send x-api-key or api_key with every request.

404Not Found

Unknown endpoint. Valid paths are /from-url and /from-html under /api/v1/pdf-generation.

429Rate Limit

More than 10 requests in 15 minutes. The limit is intentionally low because rendering is CPU and memory intensive.

503Service Busy

The browser pool is saturated. Retry with backoff; the pool is shared with scraping workloads.

504Render Timeout

Chromium navigation or rendering timed out. Simplify the page or adjust waitUntil.

Example error response

{
  "success": false,
  "error": "Invalid input parameters",
  "details": [
    "\"url\" is required"
  ],
  "correlationId": "req_error123"
}

FAQ

API questions developers ask first.

Can I generate a PDF from raw HTML instead of a URL?

Yes. POST /from-html accepts an HTML string up to 512,000 characters, sanitizes it, and renders it with headless Chromium. Use POST /from-url when you want to render an existing public web page instead.

What page formats and layout options are supported?

A4, Letter, Legal, and Tabloid formats; per-side margins in mm, cm, in, or px; landscape orientation; page ranges; and Chromium header/footer templates for page numbers and titles.

How do I get the PDF back?

Set responseType to binary (default) for raw application/pdf bytes with an inline Content-Disposition, or base64 for a JSON payload containing pdfBase64 plus metadata like byteLength and timingMs.

Is rendering safe against SSRF?

Yes. URL targets pass SSRF guards before navigation and on redirects, and HTML input is sanitized before rendering. The browser pool is shared with scraping workloads and returns 503 when saturated.

Why is the rate limit lower than other APIs?

PDF rendering is CPU and memory intensive, so the service allows 10 requests per 15 minutes. For higher volume, batch your work and handle 429 responses with backoff.

Ship invoices and reports as PDFs.

Render from a URL or HTML with full control over format, margins, and headers. Chromium, SSRF guards, and sanitization are handled for you.