PDF.cool

HTML to PDF conversion API

50,000 PDFs for $9 Learn how to use

How to use

Use the following samples to understand how the API works. You can change the example codes to try on your site.

Basic configuration

Here are all the basic configuration options you can provide when generating PDFs.

curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://distill.pub/2016/augmented-rnns/",
  "screen": false,
  "scale": 1,
  "displayHeaderFooter": false,
  "printBackground": false,
  "landscape": false,
  "pageRanges": "",
  "format": "Letter",
  "margin": {
    "top": "24px",
    "right": "16px",
    "bottom": "24px",
    "left": "16px"
  }
}' \
"https://pdf.cool/generate"

Add custom CSS

Apart from the basic configuration options, you can pass a custom CSS which will be applied to the generated page. This is useful when you want to specify custom page breaks.

curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://distill.pub/2016/augmented-rnns/",
  "css": "h2 { page-break-before: always; page-break-after: avoid; } h3 { page-break-after: avoid } figure, ul, ol { page-break-inside: avoid } dt-appendix, dt-appendix h3 { page-break-before: always }"
}' \
"https://pdf.cool/generate"

Inline HTML

Instead of an URL, you can provide a HTML block to be converted to PDF. You can also apply CSS to it.

curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "html": "<address>Ship to:<br>Apple<br>1 Infinite Loop<br>Cupertino, CA 95014<br>(408) 996–1010</address>",
  "css": "address { font-size: 32px; margin: 30vh 20vw; }"
}' \
"https://pdf.cool/generate"

Wait for elements to load

You can ask the generator to wait for a given number of seconds or certain elements to load (specificed as a CSS selector) before generating the PDF.

curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://atlas.media.mit.edu/en/visualize/embed/tree_map/hs92/export/nzl/all/show/2016/",
  "wait": "#data .d3plus_rect",
  "screen": true
}' \
"https://pdf.cool/generate"

View complete documentation

PDF.cool runs each request in a separate browser context and doesn't retain any data from a session.

Get a token

A token will be valid for 365 days. You can make 50,000 successful requests.

Generating PDF
Failed to generate the PDF.

🎉 Thanks for the payment

Here is your token (it was also emailed to you):