Free tool · HTML and CSS to PDF
HTML to PDF
Paste HTML, add CSS if you like, and download it as a PDF. The HTML is printed by a real browser, so your CSS, web fonts, @media print rules and page breaks work as in Chrome. No sign-up.
HTML to PDF in three steps
- Paste the HTML (a whole document or a fragment) or open an
.htmlfile from your computer. Put extra CSS in the CSS field if you want to keep it apart. - Choose the layout: paper size (A4, Letter, Legal or A3), portrait or landscape, margins, and whether the
printorscreenCSS rules apply. - Create the PDF, check the preview and download it.
What works in the HTML
| Feature | Works? |
|---|---|
CSS, flexbox and grid, @media print | Yes, as in Chrome |
Web fonts (@font-face, Google Fonts) | Yes, from absolute https:// URLs |
| Images, SVG, background images | Yes, inline or from absolute https:// URLs |
| JavaScript (charts, templating) | Yes; it has to finish within the render time |
Page breaks (break-before, break-inside: avoid) | Yes |
Relative URLs (/css/style.css, img/logo.png) | No: the HTML has no address. Use absolute URLs or a <base href> |
http:// resources | Upgraded to https or blocked, as on any https page |
Several pages or one long page
A normal PDF splits the document into sheets of the chosen paper size. With Whole document on one long PDF page, you get everything on a single page as wide as the paper and as tall as the content (up to 200 inches): good for receipts and long reports you want to keep in one piece.
Limits
| Limit | Value |
|---|---|
| HTML size | 1 MB in this tool, 5 MB with the API |
| Time per PDF | about 12 seconds to render and print; slower documents are stopped |
| Pages | at most 30 |
Convert HTML to PDF from your code
The HTML to PDF API does the same in one request: POST the HTML in a JSON body to /v1/take with format=pdf and get the PDF back. It adds what the tool leaves out: custom margins per side, scaling, page ranges, a wait for late content and a file name for the download. See the Render HTML documentation. To print a web page by its address instead, use URL to PDF.
Frequently asked questions
How do I convert HTML to PDF?
Do CSS and web fonts work?
Is my HTML stored?
Why does the PDF hide some parts of my page?
How large can the HTML be?
How many PDFs can I create for free?
HTML to PDF API
Create PDFs from your HTML templates
POST /v1/take with html and format=pdf prints the HTML your application generates, such as invoices, reports or certificates, and returns the PDF: paper size, orientation, margins, print or screen styles, page ranges, or the whole document on one long page.
/v1/take documentation HTML to PDF API All documentation
300 free requests every month, and each PDF counts as one. HTML up to 5 MB. No credit card required.
POST https://api.screenshotbase.com/v1/take
# Response: the PDF (application/pdf)
curl -X POST "https://api.screenshotbase.com/v1/take" \
-H "apikey: YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice INV-42</h1>", "format": "pdf", "pdf_margin": "15mm"}' \
-o invoice.pdf