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 5 MB (5,242,880 bytes). 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 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: A4, Letter, Legal or A3, margins in mm, cm, in or px, at most 30 pages, or one long page.
- wait_until, delay, hide_selectors, styles
- Wait for scripts or late content (
delayat most 7 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.
- url
- The same endpoint also renders a URL. Send either
urlorhtml, not both.
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. It passes upload: true and gets 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. 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).