Skip to content

Convert HTML to PDF with one request

To convert HTML to a PDF, send the HTML to CurlShot in a POST request with format=pdf. A real browser lays the page out and prints it, so your CSS, web fonts, tables and images come out as they look on screen, with text you can select and search. Paper size, margins, orientation and background printing are options.

Request
curl -X POST "https://curlshot.com/api/v1/screenshot" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Invoice 1042</h1><p>Total: 120.00</p>","format":"pdf","pdf_paper_format":"a4","pdf_margin":"20mm"}' \
  --output invoice.pdf

How to do it, in three steps

  1. 1

    Write the document as HTML and CSS, as you would a web page.

  2. 2

    Send it in a POST request with format set to pdf and the paper size you want.

  3. 3

    Save the PDF that comes back, or make one for every order, user or report.

What people use it for

  • Invoices and receipts from an HTML template
  • Reports and statements with tables and charts
  • Tickets, certificates and contracts with the details filled in
  • A printable version of a page of your app

For developers: one request

The same thing from your own code. It is a plain HTTP request, so it works from any language. Create a free account to get an access key.

Questions people ask

How do I convert HTML to PDF?

Send the HTML to CurlShot in the html field of a POST request and add format=pdf. The answer is the PDF file.

Do backgrounds and colors print?

Yes. Background colors and images are printed unless you switch them off with pdf_print_background=false, for a document that saves ink.

Can I control page breaks?

Yes, with normal CSS. Rules such as break-before, break-after and break-inside work as they do when a browser prints.

Can the whole document be one long page?

Yes. pdf_fit_one_page puts everything on a single tall page with no breaks.

Take as many screenshots as you need

A free account gives you 100 screenshots every month and keeps them in one place. No card needed.