Headless browser or HTML to PDF API? How to choose
Turning URLs into PDFs from code comes down to two roads, plus a third worth knowing about. Here's what each is good and bad at, and when to use which.

You've got a list of URLs, and your code needs a PDF of each one. There are two usual roads: run a headless browser yourself, or send the pages to a hosted HTML to PDF API that runs one for you. There's also a third kind, which happens to be ours: an API that hands back the article on the page rather than a copy of the whole screen. Which one's right depends on what the PDF is for, so here's what each is good and bad at.
What a headless browser gives you
A headless browser is Chrome with no window, driven from code. The simplest version is one command: Chrome's headless mode has a --print-to-pdf flag that saves the page it loads as a PDF.
chrome --headless --print-to-pdf https://example.com
For anything past a one-off, people drive it from a browser automation library in their own language, which opens the page, waits, clicks if it has to, and prints.
What's good about it:
- It's exact. The PDF is what Chrome itself draws, so modern CSS, web fonts and pages built by JavaScript come out the way they look in Chrome's own print preview.
- You control the output. Page size, margins, backgrounds, a header and footer, and your own print stylesheet. In CSS, the
@pagerule is where a stylesheet sets the page's size, orientation and margins. - It can sign in. Your code can log in first, so pages behind an account work.
- Nothing leaves your servers. The HTML, the data in it and the finished file all stay with you.
- No fee per document. Chrome is free. You pay in servers and time.
The catch is that you run it. Every open browser takes a real chunk of memory, so making lots of PDFs at once means a queue and a cap on how many run together. Slim Linux images often come without the fonts your pages expect, and text quietly falls back to something else until you install them. Browsers sometimes hang, so something has to find stuck processes and clean them up. And Chrome puts out a new stable release every four weeks, so keeping it patched is on you, on that schedule.
For your own templates (an invoice, a report, a ticket), that's often a fair trade. The trouble starts when the URLs aren't yours.
The part nobody mentions: real-world URLs
Most comparisons assume you're printing a page you built. Point a headless browser at somebody else's page and it prints exactly what it's served, which is a lot more than the article:
- Cookie and consent banners print right over the first page, because nobody clicked them away.
- Images that load as you scroll come out as blank boxes unless your code scrolls down the page or waits for them.
- Ads, menus, sidebars and "related stories" take up whole pages around the bit you wanted.
- Sticky headers that stay put on screen can repeat at the top of every printed page.
- "Wait until the page is done" is harder than it sounds. Pages that keep loading ads or checking for updates never go quiet, so you end up picking a timeout and hoping.
- Some sites block or challenge requests that come from servers, so you get a check page or an error instead of the article.
You can fix each of these in code: click the banner away, scroll the page, hide the clutter with CSS. But every site needs its own fixes, and sites change their layouts. It's ongoing work, not a one-time setup.
What a hosted HTML to PDF API gives you
A hosted HTML to PDF API takes your HTML or a URL over HTTP and sends back a PDF. Most of them run a browser on their side, so the result looks a lot like what you'd get from your own.
What's good about it:
- Minutes to set up. Get a key, send a request, get a file.
- No servers, no browser to patch. Memory, fonts, stuck processes and Chrome updates are their problem.
- Scaling is theirs too. You send more requests and they handle the load, up to your plan's limits.
What it costs you:
- A fee per document, usually in plans by volume, so the bill grows with you. At low volume it's cheaper than your time. At high volume, price out both before you pick.
- Your content goes to someone else's servers: the HTML you send, the pages they fetch for you, and the finished files.
- Their limits and their outages. Rate limits cap how fast you can go, and when their service is down, so is your PDF step.
- Their options, not every option. You get the settings they expose, not every switch of a browser you control.
- Some send files back as links that expire, so you download and store them yourself.
And because most of them render the page as served, the real-world URL problems above mostly come along for the ride. Some offer settings to hide elements, block ads or wait longer, which help on some sites. Test whatever you pick against the actual pages you need.
A third kind: an API that returns the article
The PrintFriendly API works differently. Send it a URL and it keeps the article: the headings, text, images and tables, with the ads, menus and other clutter left out, laid out for Letter or A4 pages. You get it back as a PDF, a Word file, Markdown, HTML, JSON or plain text. It takes your own HTML or Markdown too.
Here's what it isn't. It doesn't give you a picture of the page as it looks on screen. HTML you send is treated as the body of an article (scripts and anything unsafe are removed) and gets our print styling, so it's the wrong tool for an invoice, a receipt, a ticket or anything that has to match a design exactly. For those, use one of the two roads above.
The practical bits:
- A free key comes with 100 documents a month and needs no credit card. PDFs from the free plan carry a one-line credit at the foot of each page. Paid plans don't.
- Slow pages can run in the background, with the finished job sent to your webhook.
- File links stay valid for 48 hours, so download what you want to keep.
- It doesn't sign in to sites. For a page behind a login, get the HTML yourself and send that.
Formats, options and limits are all in the API docs.
Side by side
| Headless browser you run | Hosted HTML to PDF API | PrintFriendly API | |
|---|---|---|---|
| Setup | Install Chrome, write the code, build a queue | Get a key, send a request | Get a key, send a request |
| Browser to run and patch | Yours | None | None |
| What the PDF looks like | The page exactly as Chrome draws it | The page as served | The article, cleaned up for reading |
| Ads, banners and menus on other people's pages | Printed, unless you remove them site by site | Mostly printed, some have options | Left out |
| Pages behind a login | Yes, your code signs in | Usually only if you send the HTML | Only if you send the HTML |
| Your own templates, exactly as designed | Yes | Yes | No |
| Cost | Servers and your time | A fee per document | 100 documents a month free, paid plans past that |
| Your content leaves your servers | No | Yes | Yes |
| Lots at once | You build the queue | Theirs, within your plan's limits | Within your plan's limits, with background jobs |
| Formats | Usually PDF | PDF, Word, Markdown, HTML, JSON, text |
Which to use when
- One page, right now: skip code altogether. Your browser's own Print to PDF works, or PrintFriendly in the browser if you want the ads gone first. How to save a webpage as a PDF has the steps for every browser.
- Your own templates, modest volume, and you're happy running a container: a headless browser. It's free, it's exact, and every setting is yours.
- The same templates, but nobody wants to look after Chrome: a hosted rendering API. Price it at the volume you expect a year from now, not just today's.
- Documents that must not leave your servers: run the browser yourself. Every hosted API, ours included, receives what you convert.
- Pages behind a login: a headless browser, since your code can sign in first.
- Articles from other people's sites, for reading, archiving, research or feeding an AI tool: an article API like ours, because the banners, ads and menus from the URL section are exactly what it leaves out. When a program is the reader, Markdown or JSON skips the PDF entirely.
- Huge runs of simple, fixed-layout documents where speed matters most: skip HTML and draw the PDF in code with a PDF library. It's fast and light, but you lay out every line yourself.
Frequently Asked Questions
Can I convert HTML to PDF for free?
Yes. Headless Chrome is free software you run yourself, so you pay in servers and time instead of per document. Some hosted APIs also have free monthly allowances: ours includes 100 documents a month.
How do I bulk convert HTML to PDF?
Queue the jobs. With a headless browser, that's a pool of workers capped by how much memory you have. With an API, it's a loop of requests that stays inside its rate limits, using background jobs for slow pages if it offers them.
What is the best HTML to PDF converter?
It depends on the input. Your own templates want an exact renderer, either a headless browser or a hosted rendering API. Other people's articles want the article without the ads and menus.
Do I need a headless browser to make a PDF from a URL?
No. A hosted API fetches and renders the page for you. You only need your own browser when you want full control, need to sign in to the page, or want everything to stay on your servers.
Sources
- Chrome Headless command-line reference, Google Chrome for Developers. Chrome's headless mode can save a page as a PDF from the command line with the --print-to-pdf flag.
- CSS Paged Media Module Level 3, W3C. The W3C's CSS Paged Media module defines the @page rule for setting page size and margins in print.
- Chrome Release Channels, The Chromium Projects. Chrome releases a new stable version every four weeks.








