URL to PDF
URL to PDF is an API that opens a web page the way a real browser would and returns a PDF of it, with its images, fonts and styles. It is useful for archiving a page, emailing it, saving an online receipt or attaching it to a record. If what you have is your own HTML (an invoice, a report), use HTML to PDF.
How it works
You send the url and get the PDF back. It opens the page with JavaScript, waits for it to load, scrolls it once from top to bottom so the images and sections that only load when you reach them show up, and prints it. By default it comes out the way it looks on screen (media=screen); with media=print it uses the site's own print stylesheet.
Honest note: the PDF is as wide as the paper (an A4 is about 800 pixels), so many sites come out with their tablet or mobile layout. For the desktop layout use landscape=true or scale=0.7. It can't get into pages that ask you to sign in, that ask you to prove you're a person, or that block robots: in that case it returns an error and the credit isn't charged. If the site shows a cookie notice, it will be in the PDF: you can hide it with css (for example .cookie-notice{display:none}).
Use it only on pages you have the right to save or copy, respecting each site's terms and copyright. Up to 100 pages and 25 MB of PDF per call.
All you need
- Your API key. Create it in your dashboard with "+ Create key".
- In your automation platform, an "HTTP Request" step (n8n, Make, Zapier, Pipedream…).
How to use it in n8n
- Method:
POST· URL:https://api.cofferdock.com/url-to-pdf - Send Headers:
x-api-key= your key,Content-Type=text/plain - Send Body: type
Rawand, as the content, the address of the page:https://example.com/article - Under Options → Response → Response Format pick File: the result is the PDF, ready for Drive, Gmail or Telegram.
Options
In n8n they go as Query Parameters, for example format = A4.
| Option | Default | What it does |
|---|---|---|
format | A4 | Paper size: A4, A3, A5, Letter, Legal or Tabloid. |
landscape | false | Landscape paper (wider). It helps the site come out with its desktop layout. |
media | screen | screen = as it looks on screen; print = with the site's print stylesheet. |
margin | 0 | Margin in millimetres (0 to 100), the same on all four sides. |
pages | 1 to 100 | Which pages of the PDF you want, for example 1-3,5. |
css | - | Extra styles to hide or change parts, for example a cookie notice. |
API overview
- Endpoint:
POST https://api.cofferdock.com/url-to-pdf - Auth: header
x-api-key: YOUR_KEY. - Input: JSON
{ "url": "https://...", ... }or raw: the URL astext/plain, with the options in the query string. - Output (
output):json(the PDF in base64 plus its details; the default with JSON input),pdforbinary(the PDF itself; the default with raw input) orurl(a temporary download link, valid 15 minutes). - How it loads the page: with the same browser and the same protection as Website screenshot (it can't be pointed at internal addresses, and redirects towards them are not followed), JavaScript on. WebSockets and downloads are blocked, the web page cannot register service workers, and pop-up windows are closed as soon as they open. It stores no cookies or data from anyone: every call opens a clean browser. It accepts no custom headers or cookies and no addresses with a user name and password.
- Steps: load (up to 25 s) → wait for the network to settle (up to 3 s) →
wait_ms→ scroll from top to bottom (lazy_load, up to 4 s) →css→ print. The whole job has a 50 s cap. - Errors:
400ifurlis missing or an option isn't valid;502if the page doesn't load or answers with an HTTP error (not charged);422if the URL is a download and not a web page, the PDF would go over 25 MB or it takes too long (not charged);503withRetry-Afterif the server is busy (not charged). - Limits: 20 requests/min per IP. Up to 100 pages and 25 MB per call. One web page per call. 1 call = 1 credit.
Options
| Option | Default | Description |
|---|---|---|
url | - | http(s) address of the page. Required (up to 8192 characters). |
format | A4 | A4, A3, A5, Letter, Legal or Tabloid. |
landscape | false | Landscape paper. |
media | screen | screen or print (the site's print stylesheet). |
margin | 0 | 0 to 100. Millimetres, the same on all four sides. |
print_background | true | Print background colours and images. |
scale | 1 | 0.1 to 2. With a value below 1 more fits on each sheet and the site comes out with a wider layout. |
pages | 1-100 | Which pages of the PDF, for example 1-3,5. Only the first 100 are printed. |
wait_ms | 0 | 0 to 5000. Extra wait, in milliseconds, before printing. |
lazy_load | true | Scrolls the page once from top to bottom before printing, so lazy images and sections load. With false that step is skipped (faster). |
css | - | Up to 20,000 characters of CSS applied to the page before printing, for example .cookie-notice{display:none}. |
output | json / pdf | json, pdf (or binary) or url. |
Example
curl -X POST "https://api.cofferdock.com/url-to-pdf" \
-H "x-api-key: YOUR_KEY" -H "Content-Type: application/json" \
-d '{ "url": "https://example.com/article", "format": "A4", "output": "url" }'
Response
{ "success": true, "pdf": "JVBERi0xLjQK...", "mime_type": "application/pdf",
"meta": { "url": "https://example.com/article", "title": "How to do something",
"format": "A4", "pages": 3, "size_bytes": 184233, "used": 12, "remaining": 488 } }
What you get back
The PDF, and in meta: the page's final address after redirects (url), its title (title), how many pages the PDF has (pages) and its size. If pages is 100, the web page may have been longer and was cut there. If the page can't be opened, takes too long or is a download, you get a clear error and the credit isn't charged.