The journal · 14 November 2026 · 7 min read
Playwright HTML to PDF in Production and What a Year of Self-Hosting Really Costs
Playwright page.pdf() is free and accurate. One box prints 2,700 PDFs an hour, so a 50,000 document month-end run takes 18.5 hours. Here is the full year of cost against an API.
Live demo
Runs in your browser. Nothing is uploaded. One PDF free to try, then a plan.
Your HTML
Live preview
Your PDF is downloading. That was the free one. The Starter plan converts as many as you need, for $49 a month or $288 a year, half price.
See the planPlaywright's page.pdf() is free, accurate and takes ten lines to wire up, which is exactly why teams ship it without pricing it. The question that matters for a buyer is not whether it works on your laptop. It is how many documents per hour a box can print, what happens on the night 50,000 invoices need rendering at once, and whether the engineering hours behind it cost more than a rendering API. This article works one example through with the arithmetic shown, so you can swap in your own numbers.
The short answer
Playwright for HTML to PDF is the right choice up to a few thousand documents a month, when a developer on your team is happy to own a browser in production. Past that, or when volume arrives in batches, the compute is still cheap but the engineering time is not. In the example below, a year of self-hosting costs roughly seven times the yearly price of a 50,000 render API plan, almost all of it people time rather than servers.
How does Playwright generate a PDF?
Playwright launches headless Chromium, loads your page or HTML string, waits for the page to settle and calls Chromium's print to PDF. The page.pdf() reference documents the options: paper format, margins, background printing, and header and footer templates. Two details matter for production. PDF output works only in headless Chromium, so you cannot fall back to Firefox or WebKit for it. And the output matches Chrome's print preview, which is why it solves the layout and JavaScript problems that libraries like WeasyPrint and dompdf cannot.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.set_content(html, wait_until="networkidle")
page.pdf(path="invoice.pdf", format="A4", print_background=True)
browser.close()
That snippet is the whole prototype, and it is the reason the cost question gets skipped. Everything below is what the snippet leaves out.
What does one Playwright box actually handle?
Take a realistic job. Each render takes 4 seconds, covering page load, a web font, a chart and the print itself. You size the service for 3 concurrent renders, which on an assumed 400 MB per page leaves a 4 GB machine with room for the operating system and Chromium overhead. Measure your own page memory before copying that figure.
| Setup | Concurrent renders | Throughput | Time to render 50,000 documents |
|---|---|---|---|
| One self-hosted box | 3 | 0.75 per second, 2,700 per hour | 18.5 hours |
| Two boxes behind a queue | 6 | 1.5 per second, 5,400 per hour | 9.3 hours |
| SitePDF Growth tier | 10 | 2.5 per second, 9,000 per hour | 5.6 hours |
Average load is easy: 50,000 documents a month over 22 working days is about 2,270 a day, and even if 40 percent land in the busiest hour that is roughly 900 renders needing about one concurrent slot. One box copes with ordinary days. The problem is the month-end run. Billing, statements and compliance exports tend to fire all at once, and 18.5 hours to clear the queue means customers wait until the next morning for documents they expected at 9 a.m. Fixing it means more boxes, a queue, retries and autoscaling, which is a project, not a setting.
What does it cost to run Playwright for PDFs in production?
Compute is the small part. Our Lambda cost breakdown shows Chrome itself costing around ten dollars per 100,000 renders on serverless. The real bill is the work around it, and that is where teams under-count. Here is a year of owning the service under stated assumptions.
| Item | Assumption | Year one |
|---|---|---|
| Initial build | 16 hours: Docker image with fonts, queue, timeouts, retries, crash recovery | $1,600 |
| Upkeep | 2 hours a month: Playwright and Chromium updates, font fixes, incidents | $2,400 |
| Servers | Two small instances for headroom, your cloud rate | your rate |
| Total labor | $100 an hour loaded cost, which is an assumption | $4,000 |
| SitePDF Growth, 50,000 renders a month | $588 billed yearly, $99 monthly | $588 |
$4,000 against $588 is about 6.8 times before a single server is paid for. Change the hourly rate or the hours and the ratio moves, but it takes very optimistic numbers to flip it at 50,000 a month. Below roughly 2,000 documents a month the same arithmetic favors Playwright, because the build is a one-off and nothing runs in batches. Plan details are on the pricing page.
What goes wrong in production
These are the items behind the upkeep hours above, and each one has bitten a team that thought the prototype was done.
- Shared memory in Docker. Chromium crashes under load in containers with a small
/dev/shm, and the failure looks like a random timeout. - Fonts. A slim image has no fonts, so text silently falls back to a default face. Every font your templates use has to be installed in the image or loaded reliably from the page.
- Waiting for the page.
networkidlereturns too early on charts that animate and too late on pages that poll. See timeouts on large pages. - Zombie browsers. A crashed render can leave a Chromium process holding memory until the box falls over.
- Untrusted URLs. If users can supply a URL, your renderer can reach your internal network unless you block it. The security notes on rendering APIs cover the controls.
When Playwright is still the right call
Keep it if volume is low and steady, documents render from trusted templates you control, and someone on the team already runs containers and wants this. The same goes if the rule is that rendered content must never leave your network. In those cases the free license is real value. Compare the Node-side equivalent on the Puppeteer alternative page, which hits the same operational points.
If you are still deciding how the finished document should look, a searchable gallery of design styles is a quick way to settle the layout before you write the template.
When to switch to an API
Switch when documents arrive in bursts, when a render failure costs you a customer, or when the hours above are hours you would rather spend on the product. A rendering API turns the whole table above into one HTTP call, and SitePDF adds a dated archive of every render, which matters when invoices and contracts are evidence. The PDF generator API page shows the request and the response, and the cost of the alternatives is laid out on PDF API pricing. Running Go instead of Node or Python? The same sums with a chromedp pool are in chromedp PDF in production.
Frequently asked questions
Does Playwright support PDF generation in Firefox or WebKit?
No. Playwright can create PDFs only in headless Chromium. Firefox and WebKit builds do not expose the print to PDF function, so a service built on page.pdf() depends on Chromium releases and their update cycle.
Is Playwright better than Puppeteer for HTML to PDF?
For PDF output they are close, because both drive the same Chromium print path. Playwright has stronger waiting helpers and first class Python, .NET and Java clients, so it is the easier pick outside Node. The production costs described here apply equally to both.
How many PDFs per hour can one Playwright server generate?
Divide concurrent renders by render time. With 3 concurrent pages and 4 seconds per render, one box produces 2,700 PDFs an hour. Real figures depend on page weight and memory, so measure a representative template before sizing anything.
For a priced example of the hosted route, see HTML2PDF API pricing for 10,000 PDFs a month.
Written by the team behind SitePDF, an HTML to PDF API that archives every page it renders. The in-browser converter is free to try, and API plans start at $49 a month, half price billed yearly.