Tools API Blog
Sign in Create account

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 Raw and, 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.

OptionDefaultWhat it does
formatA4Paper size: A4, A3, A5, Letter, Legal or Tabloid.
landscapefalseLandscape paper (wider). It helps the site come out with its desktop layout.
mediascreenscreen = as it looks on screen; print = with the site's print stylesheet.
margin0Margin in millimetres (0 to 100), the same on all four sides.
pages1 to 100Which pages of the PDF you want, for example 1-3,5.
css-Extra styles to hide or change parts, for example a cookie notice.

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.