HTML a PDF
HTML a PDF es una API que convierte un diseño en HTML en un documento PDF. Le mandas tu diseño y te devuelve el PDF, listo para guardar, enviar por email o imprimir. Perfecto para generar facturas, informes, tickets o certificados automáticamente desde n8n, Make o Zapier, sin montar servidores.
Cómo funciona
Esta herramienta convierte un diseño en HTML (texto con el aspecto que quieres, con su CSS, imágenes y tipografías) en un PDF. Tú le mandas el diseño y te devuelve el PDF, listo para guardar, enviar o imprimir.
Está pensada para usarla desde plataformas no-code como n8n, Make o Zapier, sin programar. Ideal para crear documentos automáticamente: facturas, informes, tickets, certificados, etc. No guarda nada: el PDF se genera al momento.
Lo único que necesitas
- Tu API key (tu “contraseña” para la herramienta). La creas en tu panel con “+ Crear llave”. Se muestra una sola vez, así que cópiala y guárdala.
- En tu plataforma de automatización, un paso de tipo “HTTP Request” / “Hacer una petición HTTP” (lo tienen n8n, Make, Zapier, Pipedream…).
Cómo usarlo en n8n (paso a paso)
Le envías tu HTML tal cual y te devuelve el PDF directamente, listo para usar. En el nodo HTTP Request:
- Method:
POST - URL:
https://api.cofferdock.com/pdf - Send Query Parameters: actívalo y añade
format=A4(y lo que quieras:landscape,margin… ver la tabla). - Send Headers: actívalo y añade dos:
x-api-key= tu llave, yContent-Type=text/html - Send Body: actívalo → Body Content Type: Raw → en Body pega tu HTML (o conéctalo desde un paso anterior)
- En Options → Response → Response Format: elige File
La salida del nodo ya es el PDF como archivo: conéctalo directamente a Drive, email, Telegram… Un solo nodo y listo.
En Make (módulo HTTP → Make a request): mismo método y URL, en Query String añade format, en Headers las dos cabeceras, Body type: Raw, Content type: text/html y pega tu HTML en Request content. La respuesta ya es el archivo PDF.
En resumen: POST a …/pdf, el parámetro format como Query Parameter, las cabeceras x-api-key y Content-Type: text/html, el HTML en Body en modo Raw y Response Format en File.
Opciones (en Query Parameters)
Opciones que puedes añadir como Query Parameters (campos name/value en n8n/Make):
| Opción | Por defecto | Para qué sirve |
|---|---|---|
format | A4 | Tamaño: A4, A3, A5, Letter, Legal, Tabloid. |
landscape | false | Apaisado (horizontal). Ponlo en true. |
margin | 0 | Margen en milímetros (0–100), igual en los 4 lados. |
scale | 1 | Escala del contenido (0,1–2). |
print_background | true | Imprimir fondos y colores. Ponlo en false para fondo blanco. |
Imágenes y fuentes de internet: puedes usar fotos, logos o tipografías alojadas en internet poniendo su enlace (https://…) dentro del HTML/CSS, y se cargarán en el PDF. El diseño se renderiza sin ejecutar JavaScript, así que usa HTML y CSS.
Resumen de la API
- Endpoint:
POST https://api.cofferdock.com/pdf - Auth: cabecera
x-api-key: TU_LLAVE. - Entrada: el HTML va en el cuerpo como
text/html(a pelo) o comoapplication/jsonen el campohtml. - Salida: por defecto, con
text/htmldevuelve el binario del PDF (application/pdf); con JSON devuelve base64 en el campopdf. Añadeoutput=pdfpara forzar el binario. - Opciones: en Query Parameters o en el JSON (si coinciden, gana el JSON).
- Límites: HTML máx. 5 MB; timeout 30 s; JavaScript desactivado (solo HTML/CSS); 30 PDFs/min por IP. 1 PDF = 1 crédito.
Opciones
| Opción | Por defecto | Descripción |
|---|---|---|
format | A4 | A4, A3, A5, Letter, Legal, Tabloid. |
landscape | false | Orientación apaisada. |
margin | 0 | Margen en mm (0–100), igual en los 4 lados. |
scale | 1 | Escala del contenido (0.1–2). |
print_background | true | Imprimir fondos/colores. |
output | según modo | pdf (binario) o json (base64). |
Ejemplos
curl (HTML a pelo, guarda el PDF en un fichero):
curl -X POST "https://api.cofferdock.com/pdf?format=A4" \
-H "x-api-key: TU_LLAVE" \
-H "Content-Type: text/html" \
--data-binary "<h1>Factura 001</h1><p>Total: 100 €</p>" \
-o documento.pdf
JavaScript (Node 18+):
const r = await fetch('https://api.cofferdock.com/pdf?format=A4', {
method: 'POST',
headers: { 'x-api-key': 'TU_LLAVE', 'Content-Type': 'text/html' },
body: '<h1>Factura 001</h1>',
});
const buffer = Buffer.from(await r.arrayBuffer());
require('fs').writeFileSync('documento.pdf', buffer);
Python:
import requests
r = requests.post(
'https://api.cofferdock.com/pdf',
params={'format': 'A4'},
headers={'x-api-key': 'TU_LLAVE', 'Content-Type': 'text/html'},
data='<h1>Factura 001</h1>'.encode('utf-8'),
)
open('documento.pdf', 'wb').write(r.content)
Modo JSON (respuesta en base64)
Con Content-Type: application/json, el HTML va en html y las opciones en el mismo objeto. La respuesta trae el PDF en base64:
{ "html": "<h1>Factura</h1>", "format": "A4", "landscape": false }
→ { "success": true, "pdf": "JVBERi0xLjQ…", "mime_type": "application/pdf",
"meta": { "used": 12, "remaining": 488, "size_bytes": 18421 } }
Añade "output": "pdf" al JSON para recibir el binario en lugar del base64.
Lo que recibes
El PDF directamente (un archivo .pdf), listo para guardar, enviar por email o imprimir. No hay que convertir nada: el paso siguiente de tu automatización ya recibe el archivo. (En el modo técnico con JSON, el PDF llega en base64.)
Si en un pico recibes “ocupado”
En momentos de mucha demanda, la API puede responder “ocupado” (código 503) y pedirte que esperes unos segundos. Es raro y puntual, pero para que tu automatización lo resuelva sola, activa el reintento en el paso de la petición:
- En n8n: en el nodo HTTP Request, pestaña Settings, activa “Retry On Fail”. Con 2–3 intentos sobra.
- En Make: añade un manejador de errores al módulo (clic derecho → Add error handler) con la directiva Break, que reintenta automáticamente.
Nuestra respuesta incluye la cabecera Retry-After con los segundos que conviene esperar. Con el reintento activado, tu flujo ni se entera.
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.
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.