HTML to PDF API
HTML to PDF API
POST the HTML your application generates, such as an invoice or a report, and get back a PDF printed by a headless Chromium browser. CSS, web fonts and JavaScript work as in a browser, and every PDF option of the API applies: paper size, margins, page ranges, print or screen styles.
Example request and response
Send the HTML and the options as JSON to POST /v1/take. The answer is the PDF itself; errors come back as JSON with a status code. The Render HTML documentation has examples in JavaScript, Python and PHP.
curl https://api.screenshotbase.com/v1/take \
-H "apikey: YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice INV-42</h1><p>Total: EUR 49.00</p>", "format": "pdf", "pdf_margin": "15mm"}' \
-o invoice.pdf
HTTP/1.1 200 OK
Content-Type: application/pdf
X-Cost: 1
(the PDF, served as a download)
The request body
- html
- The HTML to render, at most 10 MB (10,485,760 bytes), or 50 MB as an async job. A whole document or a fragment. It is accepted in the JSON body only, never in the query string.
- format
pdffor a PDF. The same HTML can also become a PNG, JPG, WebP, AVIF or GIF screenshot.- pdf_paper_format, pdf_landscape, pdf_margin, pdf_media_type, pdf_scale, pdf_page_ranges, pdf_fit_one_page
- The PDF options, as for web pages: A0 to A6, Letter, Legal, Tabloid, Ledger or any size with
pdf_widthandpdf_height, margins in mm, cm, in or px, at most 200 pages, or one long page. - pdf_header_template, pdf_footer_template
- HTML printed at the top and the bottom of every page, up to 16 KB each, with
{page},{total},{date},{title}and{url}filled in.pdf_outlineadds bookmarks from the headings. - wait_until, delay, hide_selectors, styles
- Wait for scripts or late content (
delayat most 30 seconds), hide elements, add CSS. - attachment_name, upload
- Name the download, or store the PDF and get JSON with its URL instead. Anyone with that URL can open a stored file.
- markdown
- Markdown (GitHub flavor, up to 1 MB) instead of HTML, rendered as a page in a readable default style that
stylescan change. It costs the same as HTML. - url
- The same endpoint also renders a URL. Send only one of
url,htmlandmarkdown.
Use cases
Invoices and receipts
Render the invoice template your application already has, with your fonts and logo, as an A4 or Letter PDF.
Reports and statements
JavaScript runs before the page is printed, so charts drawn by script can be included; use wait_until or a short delay for late ones.
Certificates, tickets and labels
Design them in HTML and CSS, choose the paper size and margins, and print one PDF per recipient.
Quotes and contracts
Generate a PDF from the same HTML your customers see in the browser, with the page's print stylesheet.
AI agents
Through the MCP server, an agent sends HTML with the takePost tool and gets the PDF or image back in the tool result, or, with upload: true, the URL of the stored file.
Start on the free plan
Rendering HTML is part of every plan, including the free plan with 300 requests a month. Each successful render counts as one request, whatever the format and also with upload=true; failed renders are not counted, except the failure conditions you set past 25 a day (see pricing). Paid plans start at $15 a month for 3,000 requests.
Frequently asked questions
Do relative URLs in my HTML work?
Do you keep my HTML?
upload=true, and a stored file can be opened by anyone with its URL. For documents with personal data, such as invoices, take the PDF from the response instead.Can the HTML load files from my internal network?
How long may a render take?
Does JavaScript in my HTML run?
wait_until or a short delay if content appears late.Can I test without using my quota?
X-Cost: 0).