HTML to PDF
HTML to PDF is an API that turns an HTML design into a PDF document. You send your design and get the PDF back, ready to save, email or print. Great for generating invoices, reports, tickets or certificates automatically from n8n, Make or Zapier, with no servers to maintain.
How it works
This tool turns an HTML design (text describing how it should look, with its CSS, images and fonts) into a PDF. You send the design and it returns the PDF, ready to save, send or print.
It's made to be used from no-code platforms like n8n, Make or Zapier, without coding. Great for generating documents automatically: invoices, reports, tickets, certificates, etc. Nothing is stored: the PDF is generated on the fly. If what you have isn't HTML but the address of a web page, use URL to PDF.
All you need
- Your API key (your “password” for the tool). Create it in your dashboard with “+ Create key”. It's shown only once, so copy and save it.
- In your automation platform, an “HTTP Request” step (n8n, Make, Zapier, Pipedream… all have one).
How to use it in n8n (step by step)
You send your HTML as is and you get the PDF back directly, ready to use. In the HTTP Request node:
- Method:
POST - URL:
https://api.cofferdock.com/pdf - Send Query Parameters: on, and add
format=A4(and whatever you want:landscape,margin… see the table). - Send Headers: on → add two:
x-api-key= your key, andContent-Type=text/html - Send Body: on → Body Content Type: Raw → paste your HTML in Body (or connect it from a previous step)
- Under Options → Response → Response Format: choose File
The node's output is already the PDF as a file: connect it straight to Drive, email, Telegram… One node and done.
In Make (HTTP → Make a request module): same method and URL, in Query String add format, in Headers the two headers, Body type: Raw, Content type: text/html, and paste your HTML into Request content. The response is already the PDF file.
In short: POST to …/pdf, format as a Query Parameter, the x-api-key and Content-Type: text/html headers, your HTML in Body as Raw, and Response Format as File.
Options (as Query Parameters)
Options you can add as Query Parameters (name/value fields in n8n/Make):
| Option | Default | What it does |
|---|---|---|
format | A4 | Size: A4, A3, A5, Letter, Legal, Tabloid. |
landscape | false | Landscape orientation. Set it to true. |
margin | 0 | Margin in millimetres (0–100), same on all sides. |
scale | 1 | Content scale (0.1–2). |
print_background | true | Print backgrounds/colors. Set false for white background. |
Internet images and fonts: you can use photos, logos or fonts hosted online by putting their link (https://…) inside the HTML/CSS, and they'll load into the PDF. The design is rendered without running JavaScript, so use HTML and CSS.
API overview
- Endpoint:
POST https://api.cofferdock.com/pdf - Auth: header
x-api-key: YOUR_KEY. - Input: the HTML goes in the body as
text/html(raw) or asapplication/jsonin thehtmlfield. - Output: by default, with
text/htmlit returns the PDF binary (application/pdf); with JSON it returns base64 in thepdffield. Addoutput=pdfto force the binary. - Options: via Query Parameters or in the JSON (JSON wins if both are set).
- Limits: HTML max 5 MB; 30 s timeout; JavaScript disabled (HTML/CSS only); 30 PDFs/min per IP. 1 PDF = 1 credit.
Options
| Option | Default | Description |
|---|---|---|
format | A4 | A4, A3, A5, Letter, Legal, Tabloid. |
landscape | false | Landscape orientation. |
margin | 0 | Margin in mm (0–100), same on all sides. |
scale | 1 | Content scale (0.1–2). |
print_background | true | Print backgrounds/colors. |
output | per mode | pdf (binary) or json (base64). |
Examples
curl (raw HTML, saves the PDF to a file):
curl -X POST "https://api.cofferdock.com/pdf?format=A4" \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: text/html" \
--data-binary "<h1>Invoice 001</h1><p>Total: 100 €</p>" \
-o document.pdf
JavaScript (Node 18+):
const r = await fetch('https://api.cofferdock.com/pdf?format=A4', {
method: 'POST',
headers: { 'x-api-key': 'YOUR_KEY', 'Content-Type': 'text/html' },
body: '<h1>Invoice 001</h1>',
});
const buffer = Buffer.from(await r.arrayBuffer());
require('fs').writeFileSync('document.pdf', buffer);
Python:
import requests
r = requests.post(
'https://api.cofferdock.com/pdf',
params={'format': 'A4'},
headers={'x-api-key': 'YOUR_KEY', 'Content-Type': 'text/html'},
data='<h1>Invoice 001</h1>'.encode('utf-8'),
)
open('document.pdf', 'wb').write(r.content)
JSON mode (base64 response)
With Content-Type: application/json, the HTML goes in html and the options in the same object. The response carries the PDF in base64:
{ "html": "<h1>Invoice</h1>", "format": "A4", "landscape": false }
→ { "success": true, "pdf": "JVBERi0xLjQ…", "mime_type": "application/pdf",
"meta": { "used": 12, "remaining": 488, "size_bytes": 18421 } }
Add "output": "pdf" to the JSON to receive the binary instead of base64.
What you get back
The PDF itself (a .pdf file), ready to save, email or print. Nothing to convert: the next step of your automation already receives the file. (In technical mode with JSON, the PDF comes in base64.)
If you get “busy” during a spike
At peak times, the API may reply “busy” (status 503) and ask you to wait a few seconds. It's rare and brief, but to let your automation handle it on its own, turn on retry on the request step:
- In n8n: on the HTTP Request node, Settings tab, turn on “Retry On Fail”. 2–3 attempts is plenty.
- In Make: add an error handler to the module (right-click → Add error handler) with the Break directive, which retries automatically.
Our response includes a Retry-After header telling how many seconds to wait. With retry on, your flow won't even notice.