# HTML to PDF API

> POST your HTML or a public URL to https://render.cuelark.com/v1/pdf and get back a PDF printed by real Chromium, with your CSS, fonts and page size.

URL: https://render.cuelark.com/html-to-pdf-api

## Request
```bash
curl -X POST https://render.cuelark.com/v1/pdf \
  -H "content-type: application/json" \
  -d '{"html":"<h1>Invoice #1042</h1><p>Total: $1,250.00</p>","format":"letter","margin":"0.5in"}' \
  -o invoice.pdf
```

## From JavaScript
```js
const res = await fetch("https://render.cuelark.com/v1/pdf", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ url: "https://example.com", format: "a4" }),
});
const pdf = await res.arrayBuffer();
```

## Options
| Field | Values | Default |
|---|---|---|
| html or url | HTML up to 2 MB, or a public http(s) URL | - |
| format | letter, legal, tabloid, a3, a4, a5 | letter |
| landscape | true / false | false |
| margin | e.g. 0.5in, 12mm, 24px | 0.5in |
| background | print CSS backgrounds | true |
| cssPageSize | use your @page size | false |
| javascript | false to disable scripts | true |
| filename | download name | render |

## Limits and safety
- Free without a key: 10 PDF or screenshot renders per day per IP. Free API keys with 100 a month are coming with Cuelark accounts.
- Pages get 15 seconds to load. Output is capped at 12 MB.
- Private IP ranges, internal hostnames and cloud metadata addresses are blocked, also for requests made from inside your HTML.
- Your HTML and the PDF aren't stored or logged.

## FAQ
### Does it support CSS and web fonts?
Yes. It's real Chromium, so Flexbox, Grid, @font-face, Google Fonts and print CSS like @page and break-before all work.

### Letter or A4 by default?
US Letter by default. Pass "format":"a4" for A4.

### Can I call it from n8n?
Yes. Use an HTTP Request node: POST, JSON body, response format File. The PDF comes back as binary data.

### How do I add page breaks?
Add style="break-before: page" (or page-break-before: always) to the element that should start a new page.
