Skip to content

§ dompdf alternative

dompdf Alternative: 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.

Try the free converter
  • Early access, launching soon
  • No card required
  • 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.

Last updated July 2026. Written and fact checked by the Sitepdf team.

§ 00

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 planned launch pricing, labelled planned because the API is in early access.

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 $29/mo planned
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.

§ 01

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.

§ 02

mPDF: 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 HTML to PDF in PHP guide walks through each of these libraries with working code.

§ 03

Browsershot or an API: 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.

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');

The API is in early access; this is the documented call shape it opens with. Full request and response walkthrough.

§ 04

Questions about this job

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.

§ Early access

Get on the early-access list

The API opens to the list first, in order. Early access locks the planned launch rates for 12 months. No card required, launching soon.

Render + archive, one API