mPDF alternative
mPDF Alternative for PHP Teams Whose Layouts Outgrow mPDF and Memory Limits
mPDF is the step up most PHP teams take after dompdf, and for a plain invoice it works. The trouble starts with a flexbox or grid layout, a web font, a chart drawn by JavaScript, or a 400 page statement run that hits the PHP memory limit. An mPDF alternative moves the rendering out of PHP: your code sends the HTML, a managed Chromium prints it, and the PDF comes back identical to what Chrome shows.
- PDF and archive in one call
- Plans from $49 a month
- Your HTML stays yours
Short answer
The best mPDF alternative for layouts that must match the browser is a Chromium based renderer called over HTTP. mPDF implements its own HTML and CSS engine inside PHP, so flexbox and grid are not supported, JavaScript never runs, and large documents are limited by the PHP memory limit. It is also licensed under the GPL v2, which matters if you ship it inside closed source software. A rendering API such as SitePDF takes the same HTML, returns a selectable-text PDF and stores a dated copy of every render. Plans start at $49 a month for 10,000 renders.
Written and fact checked by the SitePDF team.
mPDF against a self-hosted Chromium and a rendering API, on what decides the choice
mPDF and Puppeteer are open source. The SitePDF figures come from our pricing page. The rows that usually decide it are the ones about CSS and about what happens at month-end volume.
| mPDF | Self-hosted headless Chromium | SitePDF API | |
|---|---|---|---|
| Where it runs | Inside your PHP process | Your server, with a browser you patch and scale | Managed Chromium, one HTTP call |
| CSS coverage | Its own engine, a subset. No flexbox, no grid | Full, it is Chrome | Full, it is Chrome |
| JavaScript, charts, web components | No | Yes | Yes, with a wait condition |
| Output matches the browser | Close for simple tables, often not for modern layouts | Yes | Yes |
| Right to left and complex scripts | Strong, a real mPDF strength | Good, depends on fonts installed | Good, fonts embedded as subsets |
| Very large documents | Memory grows with pages, tuned through PHP settings | Per tab memory, you size the pool | Handled outside your PHP workers |
| License | GPL v2 | Apache 2.0 (Puppeteer) | Commercial API, no library in your codebase |
| Cost | Free | Free plus servers and engineering time | From $49/mo ($288 billed yearly) for 10,000 renders, $99/mo for 50,000 |
| Dated archive of every render | No | No | Yes. archive=true, 90 days to 7 years by tier |
mPDF is the better tool when the document is mostly text and tables, when you need strong right to left or CJK handling, and when nothing may leave your own server.
When mPDF is still the right tool
mPDF is a mature PHP library with good Unicode support, right to left languages, headers and footers, bookmarks and table of contents. If your document is a text and table invoice with a fixed design and the data must never leave your own infrastructure, a library inside PHP is the simpler architecture and a service would be extra moving parts. The mPDF manual lists the supported CSS properties, which is the quickest way to check whether your template fits.
Where mPDF stops for paying customers
Modern CSS. A design that uses flexbox or grid for the header, the totals block or a card layout will not render the same way, because mPDF does not support those layout modes. Teams end up rewriting the template with nested tables just for the PDF, which means two templates to keep in step. The same ceiling is described for the other PHP engine in our dompdf alternative comparison.
JavaScript. mPDF never executes scripts. A chart drawn by Chart.js or a map arrives as an empty box, so the PDF needs a pre-rendered image of every chart.
Memory on big runs. The whole document is built in PHP memory. A monthly statement batch or a long report can exceed memory_limit and kill the worker, and raising the limit for the web tier to fix one job is an uncomfortable trade. Rendering outside PHP keeps those jobs away from your request workers.
The GPL. mPDF is GPL v2. Using it as a server side tool is common, but a team that distributes a product containing it, or whose lawyer has a view on copyleft, often prefers to call an API and keep the library out of the codebase.
The PHP convert HTML to PDF page puts mPDF next to Dompdf, Browsershot and an API.
What moving from mPDF to a rendering API looks like
You stop building the PDF in PHP and start posting HTML. In Laravel that is usually the Blade view you already show on screen, rendered to a string and sent to the API, instead of $mpdf->WriteHTML(). The nested table workaround can be deleted, because Chromium prints the real layout. The Laravel HTML to PDF page shows the swap in a queued job, and the plans and limits lists the plans, and the render call takes page size, margins and a wait condition.
A worked example with numbers
Take a PHP SaaS that sends 20,000 statement PDFs on the first of each month. With mPDF the team keeps a table based PDF template next to the flexbox web view, and a pre-rendered chart image for each statement. Assume, as a planning figure and not a measurement, 12 hours a year to keep the two layouts in step at $100 an hour, which is $1,200, plus one hour of on-call time each month when a large account exceeds the memory limit. Rendering the same web view through an API removes the second template and moves the heavy jobs off your workers. 20,000 renders fit in the Growth plan at $99 a month, or $588 a year when billed yearly at about $49 a month. Replace the hours with your own and the comparison is easy to redo.
Which alternative for which case
Fixed text and table documents, right to left languages, data that stays on your servers: keep mPDF. Layouts built with flexbox, grid or JavaScript: use Chromium. Chromium can run on your own servers, and we put numbers on that in what Playwright costs in production, or it can be called as an API. If you are weighing hosted services, the best HTML to PDF API roundup lists them with prices.
// Replaces $mpdf->WriteHTML(...) in the statement job
$html = view('statements.show', ['statement' => $statement])->render();
$response = Http::withToken(config('services.sitepdf.key'))
->asForm()
->post('https://api.sitepdf.com/v1/render', [
'html' => $html,
'format' => 'A4',
'archive' => 'true',
]);
return $response->json(); // contains the PDF URL
This is the documented API call shape. Full request and response walkthrough.
Questions about this job
What is the best alternative to mPDF?
Does mPDF support flexbox or CSS grid?
Does mPDF run JavaScript?
Why does mPDF run out of memory?
Is mPDF free for commercial use?
How much does an mPDF alternative cost?
Index
More PDF and archiving tools
- Convert HTML to PDF
- Webpage to PDF
- URL to PDF API
- Website archiving
- Monitor website changes
- Screenshot API
- React to PDF
- Java PDF library
- C# PDF library
- Python PDF generation
- HTML to PDF Node.js
- Laravel HTML to PDF
- Vue to PDF
- Next.js PDF generator
- Angular to PDF
- Markdown to PDF API
- Django HTML to PDF
- Blazor HTML to PDF
- Spring Boot HTML to PDF
- Airtable to PDF
- Svelte to PDF
- Rotativa alternative
- Zapier and Make HTML to PDF
- Golang HTML to PDF
- Rails HTML to PDF
- PDF generator API
- Website archiving software
- Document generation API
- Legal document automation software
- Document automation software
- Bulk HTML to PDF
- Accessible PDF generation
- ADA compliance audit cost
- 508 compliance testing
- PDF remediation
- VPAT and ACR
- PDF accessibility checker
- Wayback Machine alternative
- Best HTML to PDF API
- DocRaptor alternative
- Puppeteer alternative
- Wkhtmltopdf alternative
- PDFShift pricing and alternative
- Urlbox pricing and alternative
- PDFCrowd alternative
- Api2Pdf alternative
- Browserless alternative
- APITemplate alternative
- CraftMyPDF alternative
- PDFMonkey alternative
- dompdf alternative
- WeasyPrint alternative
- jsPDF alternative
- Website archiving pricing comparison
- HTML to PDF API for ecommerce
- HTML to PDF API for SaaS
- HTML to PDF API for accounting software
- PHP convert HTML to PDF
- PrinceXML alternative
- PDFreactor alternative
- PDF integrity check
- Invoice PDF archive
- PDF page numbers, headers and footers
- PDF of pages behind a login
- Website archiving for law firms
- React PDF renderer alternative
- Gotenberg alternative
- GrabzIt alternative
- Adobe PDF Services API
- PDF SDK pricing
- HTML to image API pricing
- Adobe Document Generation API pricing
- jsreport pricing
- PDFBolt pricing
- PDFEndpoint pricing
- Formstack Documents pricing
- Documint pricing
- iLovePDF API pricing
- Browserless pricing
- PandaDoc API pricing
- CloudConvert API pricing
- Encodian pricing
- IronPDF pricing
- Salesforce document generation pricing
- Winnovative pricing
- SelectPdf, HiQPdf and EvoPdf pricing
- CloudConvert alternative
- Direct mail API pricing
- E-signature API pricing
- Sparticuz Chromium Lambda cost
- Browserbase pricing
- Aspose PDF pricing
- PDF API pricing
- How it works
- Features
- Pricing
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.