Skip to content

dompdf alternative

dompdf Alternative with Real Chromium Rendering for PHP and Laravel

dompdf is the default HTML to PDF library in most PHP and Laravel projects, and its ceiling is well known: it implements its own CSS engine, roughly a subset of CSS 2.1, so flexbox, grid, modern web fonts and any JavaScript are out of reach. When your template outgrows that, the honest options are mPDF, Spatie Browsershot on your own headless Chrome, or a rendering API. SitePDF renders your HTML in managed Chromium, so the PDF matches the browser, and keeps a dated copy of it.

  • PDF and archive in one call
  • Plans from $49 a month
  • Your HTML stays yours

Short answer

People search for a dompdf alternative when a layout that looks right in Chrome comes out broken from dompdf. The cause is structural: dompdf parses HTML and CSS in pure PHP with its own engine, which is close to CSS 2.1 and does not support flexbox, CSS grid or JavaScript, and handles web fonts awkwardly. For simple documents dompdf is free and fine, so if your invoice is a basic table you should probably keep it. When you need modern CSS to survive, you have three real choices: move up to mPDF for better CSS inside the same pure PHP family, run Spatie Browsershot to drive a real headless Chrome yourself, or call a rendering API that runs the browser for you. SitePDF is the last option: send HTML or a URL, get a pixel faithful PDF from managed Chromium, with an optional timestamped archive of the source, and no browser to install on your servers.

Written and fact checked by the SitePDF team.

dompdf and the alternatives, compared honestly

dompdf and mPDF are free open source PHP libraries. Browsershot is free but you run the browser. SitePDF figures are from our pricing page.

dompdf Browsershot (self-host) SitePDF
Rendering engine Own pure-PHP engine, ~CSS 2.1 Real headless Chrome Managed Chromium
Flexbox and CSS grid No Yes Yes
Web fonts Fiddly, often wrong Yes Yes
Runs JavaScript No Yes Yes
Matches what Chrome shows Only for simple CSS Yes Yes
Infrastructure to run it None, pure PHP Node and Chrome on every server None, it is an API
Works on shared hosting Yes Usually not Yes
Cost Free Free plus your server and ops time $49/mo for the in-browser converter, API from $49/mo ($24/mo billed yearly)
Timestamped record of the source No No Yes. archive=true.

dompdf is genuinely the right tool for simple, controlled layouts, and it is free. This page is about the case where your template needs modern CSS or JavaScript that dompdf cannot render, which is when people go looking for an alternative in the first place.

Where dompdf is still the right choice

dompdf installs in one Composer command, runs in pure PHP with no system dependencies, and for a straightforward document it just works. A plain invoice, a receipt, a table heavy report, a letter: if the layout is simple and you build it with dompdf in mind, the output is fine and it costs nothing. On shared hosting where you cannot install a browser, that matters even more. Do not replace dompdf because a blog told you to; replace it when it actually fails your template.

The failure is specific and easy to recognize. Your page uses flexbox or CSS grid and the columns collapse into a stack. A web font renders as a fallback. A chart that draws with JavaScript is simply blank, because dompdf has no browser to run the script. Those are not bugs you can configure away; they are the edges of a CSS 2.1 era engine. When you hit them, it is time to move.

mPDF is the upgrade inside the pure PHP family

If dompdf is close but you need better CSS support or non Latin scripts, mPDF is the natural next step and stays inside the pure PHP world, so there is still no browser to install. It handles more CSS, has solid Unicode and right to left support, and is a reasonable pick for multilingual reports and certificates. What it does not do is change categories: mPDF still parses HTML and CSS itself rather than rendering in a browser, so flexbox, grid and JavaScript remain out of reach. If your template was designed for the web and depends on modern layout, mPDF will get you closer than dompdf but not all the way. The comparison of PHP routes further down this page puts each of these libraries against a real browser.

Snappy and wkhtmltopdf are the PHP answer to avoid in 2026

Snappy (knplabs/knp-snappy, or barryvdh/laravel-snappy in Laravel) is a PHP wrapper that shells out to the wkhtmltopdf binary, and it still shows up near the top of results for HTML to PDF in PHP. For years it was the standard way to get browser like output from PHP, because wkhtmltopdf used a real WebKit engine and handled far more CSS than dompdf.

That advice is out of date. The wkhtmltopdf project was archived in January 2023. Its frozen WebKit predates modern CSS, so flexbox and grid render inconsistently, and it carries CVE-2022-35583, a server side request forgery flaw rated 9.8 that nobody will patch. A new PHP PDF pipeline built on Snappy installs an abandoned binary with a critical open vulnerability on your servers. Keep an existing Snappy setup alive if you must while you plan the move, and see the wkhtmltopdf alternative page for the replacements by stack.

Browsershot or an API and when you need the browser

When the PDF has to match a modern browser, both honest options use one. Spatie Browsershot drives a real headless Chrome from PHP, so your flexbox, grid, web fonts and JavaScript all render correctly. The cost is that you now run headless Chrome in production: Node and Chrome installed on every server and container, kept patched, and the operational reality that the browser leaks memory, spikes CPU and crashes under concurrency. On shared hosting it is usually not even possible. We cover that true cost in the library versus API comparison and the wider case in the Puppeteer alternative page.

SitePDF runs that same Chromium for you. From PHP it is one HTTP request: no Node, no Chrome, no memory management, and it works on shared hosting because nothing renders on your box. Add archive=true and it also stores a timestamped snapshot of exactly what was rendered, retrievable later by id, which no PHP library gives you. Note that this is a different situation from Snappy over wkhtmltopdf, another popular dompdf successor, which wraps a binary that was archived in 2023 with an unpatched critical CVE; see the wkhtmltopdf alternative page for why that route is off the table for new work.

How to choose an HTML to PDF route in PHP

The choice is rarely "which PHP library is best" in the abstract. It is whether your template needs a real browser and, if it does, whether you want to run that browser yourself. Browsershot gives you Chromium but needs Node and Chrome on every server that renders, which shared hosting usually will not allow. An API call from Laravel's Http client needs nothing installed and works on any host, at a per render cost.

Your situationUse
Simple layout you control, no modern CSS or JavaScriptdompdf, or mPDF for better CSS and Unicode
Multilingual or right to left documents, still a simple layoutmPDF
Flexbox, grid, web fonts or JavaScript, and you run your own serversSpatie Browsershot (real Chrome, you own the fleet)
Same modern template on shared hosting, or no appetite to run a browserA rendering API
You need a dated record of every document, not just the fileAn API with archiving
A new project currently reaching for Snappy or wkhtmltopdfStop, pick Browsershot or an API instead

For a billing feature where the PDF has to be right every time, the API trade usually wins: no browser to patch, no 3am page when Chrome eats the memory on the invoice server, and with archive=true a timestamped copy of each document for the day someone disputes an invoice. Laravel teams can see the same options applied to Blade views on the Laravel HTML to PDF page.

From a Laravel app: render your existing Blade-generated HTML in managed Chromium, no browser to install.
$response = Http::withToken(config('services.sitepdf.key'))
    ->asForm()
    ->post('https://api.sitepdf.com/v1/render', [
        'html'    => view('invoices.show', ['invoice' => $invoice])->render(),
        'format'  => 'Letter',
        'archive' => true,   // keep a timestamped copy of this document
    ]);

$pdfUrl = $response->json('pdf_url');

This is the documented API call shape. Full request and response walkthrough.

Questions about this job

What is the best way to convert HTML to PDF in PHP?
It depends on the template. dompdf or mPDF handle simple, print style layouts with one Composer command. If the template uses flexbox, grid, web fonts or JavaScript, use real Chromium: Spatie Browsershot if you run your own servers, or a rendering API if you would rather not install a browser. Avoid Snappy and wkhtmltopdf for new work.
Why does my dompdf PDF not match how the page looks in the browser?
dompdf renders with its own pure-PHP engine that supports roughly CSS 2.1, not a real browser. Flexbox, CSS grid and JavaScript are not supported and web fonts are fiddly, so any layout built with modern CSS will not match Chrome. The fix is to render in an actual browser engine: Spatie Browsershot on your own headless Chrome, or a rendering API like SitePDF that runs managed Chromium for you.
What is the best dompdf alternative for Laravel?
It depends on your template. If it is simple but needs better CSS or non Latin scripts, mPDF is the pure PHP upgrade. If it uses flexbox, grid, web fonts or JavaScript, you need a real browser: Spatie Browsershot if you are willing to run headless Chrome yourself, or an API like SitePDF if you would rather send one HTTP request and skip the infrastructure. SitePDF also keeps a timestamped copy of each document.
Is dompdf still worth using in 2026?
Yes, for simple documents. dompdf is free, pure PHP, installs in one command and runs anywhere including shared hosting, so for a plain invoice, receipt or table heavy report it is a fine choice. It is only worth replacing when your template needs modern CSS layout or JavaScript, which its engine cannot render. Match the tool to the template rather than switching on principle.
Can I switch from dompdf without running my own browser?
Yes. A rendering API runs the browser for you, so you get real Chromium output from a single HTTP request with no Node or Chrome to install and maintain. That is the whole point of a hosted renderer like SitePDF: browser fidelity without owning the fleet, and it works on shared hosting where Browsershot cannot run. You keep your existing HTML templates and just change where they are rendered.
Does dompdf keep a record of the PDFs it generates?
No. dompdf generates a file in memory and returns it; there is no timestamped archive of what was rendered. If you need provenance for compliance or disputes, a dated snapshot you can retrieve later, that is something a library cannot give you. SitePDF adds it with archive=true on the same render call, storing the document and a retrievable record of the source together.

Index

More PDF and archiving tools

Get started

Render and archive with one API call

A pixel perfect PDF and a dated copy of the page from the same request. Plans from $49 a month, half price billed yearly.

HTML to PDF, in your browser

Buy the plan