# PD4ML for PHP Compared with mPDF, Dompdf and TCPDF

PHP developers who need HTML to PDF usually start with one of three open-source libraries: mPDF, Dompdf or TCPDF. They install with Composer, run in pure PHP and cost nothing, and for simple invoices and reports they work well. This page compares them with PD4ML for PHP, the Composer package that brings the PD4ML layout engine to PHP, so you can see where each one fits: modern CSS layout, PDF/A and PDF/UA, e-invoices, Word output, signatures, deployment and license.

The comparison covers PD4ML v4.1.1 and, marked {4.2}, features of the upcoming PD4ML 4.2 with its new v42 layout engine, which the PHP module uses by default. TCPDF is listed together with its successor, tc-lib-pdf, because its author has moved TCPDF to maintenance mode. Information about the other libraries comes from their documentation and Packagist pages as of November 2026; a cell marked "not verified" means we could not confirm it from public sources.

## At a glance

* **PD4ML for PHP** (`pd4ml/pd4ml-php`) runs the PD4ML engine in a small Java process and exposes its full API to PHP. It needs PHP 8.1 and Java 8 or later. Commercial license, perpetual, from €100; free evaluation with a watermark.
* **[mPDF](https://mpdf.github.io/)** (`mpdf/mpdf`, 8.3) is a pure-PHP library generating PDF from UTF-8 HTML, strong in right-to-left and complex scripts. GPL-2.0.
* **[Dompdf](https://github.com/dompdf/dompdf)** (`dompdf/dompdf`, 3.1) is a pure-PHP, CSS 2.1 HTML renderer with some CSS3. LGPL-2.1.
* **[TCPDF](https://tcpdf.org/)** (`tecnickcom/tcpdf`) is a long-standing PHP PDF library with a limited HTML subset, now in maintenance mode. Its successor **[tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf)** (8.x, LGPL-3.0) adds a CSS cascade, PDF/A, PDF/UA and signatures.

## Requirements, installation and license

| Item | PD4ML | [mPDF](https://mpdf.github.io/) | [Dompdf](https://github.com/dompdf/dompdf) | [TCPDF](https://tcpdf.org/) / [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf) |
|---|---|---|---|---|
| Composer package | `pd4ml/pd4ml-php` | `mpdf/mpdf` | `dompdf/dompdf` | `tecnickcom/tcpdf`, `tecnickcom/tc-lib-pdf` |
| PHP version | 8.1 or later | 5.6 to 8.5 | 7.1 or later | tc-lib-pdf: 8.2 or later |
| Runtime | PHP plus Java 8 or later | Pure PHP; `gd`, `mbstring` | Pure PHP; `dom`, `mbstring`, GD for images | Pure PHP |
| Works on shared hosting without Java | — | ✓ | ✓ | ✓ |
| Web server setup | One bridge server for PHP-FPM or mod_php (`vendor/bin/pd4ml serve`) | None | None | None |
| License | Commercial, perpetual | GPL-2.0 | LGPL-2.1 | TCPDF: LGPL-3.0; tc-lib-pdf: LGPL-3.0 or later |
| Price | €100 single, €1,600–3,200 site, €8,000–16,000 enterprise (one-time) | Free | Free | Free |
| Closed-source commercial use | ✓ Under the license | ~ GPL obligations apply when you distribute | ✓ | ✓ |
| Commercial support | ✓ | — Community | — Community | — Community |

The GPL matters if you ship software to customers: distributing an application linked with mPDF can oblige you to release it under the GPL. For a hosted web application that you do not distribute, it usually does not. Check with your legal adviser.

Install PD4ML with:

```
composer require pd4ml/pd4ml-php
vendor/bin/pd4ml install
```

Details: [PD4ML for PHP](https://pd4ml.com/docs/integrations/pd4ml-php.html).

## HTML and CSS layout support

| Feature | PD4ML | [mPDF](https://mpdf.github.io/) | [Dompdf](https://github.com/dompdf/dompdf) | [TCPDF](https://tcpdf.org/) / [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf) |
|---|---|---|---|---|
| CSS level | Modern CSS; v42 engine checked against Chrome {4.2} | CSS 2 subset with some CSS3 | Most of CSS 2.1, a few CSS3 properties | TCPDF: limited HTML subset; tc-lib-pdf: CSS cascade and `@media` |
| Flexbox | ✓ | — | — | ? |
| CSS Grid | ✓ Template areas, line names, dense placement {4.2} | — | — | ? |
| Floats | ✓ | ~ Partial; no nested floats | ~ | ~ |
| Absolute and fixed positioning | ✓ | ~ Top-level elements only | ✓ | ~ |
| CSS @page | ✓ Size, `:first`/`:left`/`:right`, named pages, margin boxes {4.2} | ✓ Named pages, own header and footer tags | ✓ | ? |
| Headers, footers, page numbers | ✓ HTML headers and footers with page and total counts | ✓ | ~ Through `@page` and page scripts | ✓ Through the API |
| Table rows split across pages | ✓ | ✓ | — A row must fit on one page | ~ |
| Repeated table headers | ✓ | ✓ | ✓ | ✓ |
| Media queries | ✓ Level 4 range syntax {4.2} | ~ | ✓ | ✓ tc-lib-pdf |
| Vector SVG | ✓ | ✓ | ✓ | ✓ |
| MathML | ✓ | — | — | — |
| Barcodes and QR codes | ✓ QR codes (`<qrcode>`) | ✓ | — | ✓ |
| JavaScript | — | — | — | — |

PD4ML's `@page` support is described in [CSS @page rules](https://pd4ml.com/docs/features/css-page-rules-page-size-margins-named-pages-and-margin-boxes.html), and its DOM API (Java, DMS and UA editions) in [modifying the HTML document before conversion](https://pd4ml.com/docs/features/modifying-the-html-document-before-conversion.html).

Dompdf documents that it does not support Flexbox or CSS Grid, and mPDF's [supported CSS list](https://mpdf.github.io/css-stylesheets/supported-css.html) does not include them either. Templates built with a modern CSS framework usually have to be rewritten with tables for those two.

## Output formats

| Format | PD4ML | [mPDF](https://mpdf.github.io/) | [Dompdf](https://github.com/dompdf/dompdf) | [TCPDF](https://tcpdf.org/) / [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf) |
|---|---|---|---|---|
| PDF | ✓ | ✓ | ✓ | ✓ |
| DOCX (Word) | ✓ | — | — | — |
| RTF | ✓ | — | — | — |
| PNG and TIFF images | ✓ | — | — | — |
| Several formats from one parse | ✓ | — | — | — |

## PDF/A, PDF/UA and e-invoices

| Standard | PD4ML | [mPDF](https://mpdf.github.io/) | [Dompdf](https://github.com/dompdf/dompdf) | [TCPDF](https://tcpdf.org/) / [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf) |
|---|---|---|---|---|
| PDF/A | ✓ PDF/A-1a/1b, 2a/2b/2u, 3a/3b/3u, 4, 4e | ✓ PDF/A-1b and PDF/A-3b | ~ Experimental PDF/A-3b mode; fonts must be embedded by you | ✓ tc-lib-pdf: PDF/A-1, 2, 3 (a, b, u) |
| PDF/UA accessible PDF | ✓ PDF/UA-1 and PDF/UA-2 | — | — | ✓ tc-lib-pdf: PDF/UA-1 and PDF/UA-2 |
| ZUGFeRD and Factur-X | ✓ Presets, including accessible PDF/A-3a invoices | ~ PDF/A-3 associated files, built by hand | — | ✓ tc-lib-pdf: `setFacturX()` |
| PDF/X for print | — | ✓ PDF/X-1a | — | ✓ tc-lib-pdf: PDF/X-1a to X-5 |
| PDF 2.0 | ✓ | — | — | ? |

See [PDF/A, PDF/UA and e-invoicing formats](https://pd4ml.com/docs/pd4ml-manual.html#11.2-pdfa-pdfua-and-e-invoicing-formats) and [ZUGFeRD and Factur-X PDF invoices](https://pd4ml.com/docs/features/zugferd-and-factur-x-pdf-invoices.html).

## Fonts and international text

| Feature | PD4ML | [mPDF](https://mpdf.github.io/) | [Dompdf](https://github.com/dompdf/dompdf) | [TCPDF](https://tcpdf.org/) / [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf) |
|---|---|---|---|---|
| TrueType and OpenType embedding with subsetting | ✓ | ✓ | ✓ Through `@font-face`; built-in fonts are Windows ANSI only | ✓ |
| Unicode by default | ✓ | ✓ | ~ DejaVu fonts preinstalled | ✓ |
| Arabic and Hebrew, right to left | ✓ | ✓ | ? | ✓ |
| Indic scripts | ✓ | ✓ | ? | ? |
| Kerning and ligatures | ✓ | ✓ OpenType layout features | ? | ? |
| WOFF2 web fonts | ✓ | ? | ? | ? |

mPDF is traditionally the strongest of the three open-source libraries for right-to-left and complex scripts.

## Security, signatures and forms

| Feature | PD4ML | [mPDF](https://mpdf.github.io/) | [Dompdf](https://github.com/dompdf/dompdf) | [TCPDF](https://tcpdf.org/) / [tc-lib-pdf](https://github.com/tecnickcom/tc-lib-pdf) |
|---|---|---|---|---|
| Passwords and permissions | ✓ RC4, AES-128/256 | ✓ | ✓ | ✓ Up to AES-256 |
| Digital signatures | ✓ PKCS#12, PKCS#11, HSM, cloud KMS, RFC 3161, PAdES-LT/LTV | — | — | ✓ tc-lib-pdf: PAdES B-B to B-LTA |
| Fillable forms from HTML | ✓ Inputs, selects, text areas, buttons | ~ | — | ✓ Through the API |
| Merge, optimize, XFDF | ✓ | ~ Import pages of other PDFs | — | ? |

## When to choose which

* **Dompdf** suits simple invoices and letters with table layouts, when you want a permissive license and the least setup.
* **mPDF** suits documents in Arabic, Hebrew or Indic scripts with traditional layout, and PDF/A-1b or PDF/A-3b archives, if the GPL fits your distribution model.
* **TCPDF** suits existing code that builds PDFs through its API. For new projects, its author recommends **tc-lib-pdf**, which adds PDF/A, PDF/UA, PDF/X and signatures.
* **PD4ML for PHP** suits templates written with modern CSS (Flexbox, Grid, `@page`), documents that also need DOCX or RTF, accessible PDF/UA and e-invoices from HTML, and teams that want commercial support. It needs Java on the server, so it is not an option on shared hosting without Java.

## Frequently asked questions

### What is the best PHP library for converting HTML to PDF?

For simple layouts without modern CSS, Dompdf and mPDF are free and need nothing but PHP. If your HTML uses Flexbox or CSS Grid, or you need PDF/UA, ZUGFeRD or Word output, PD4ML for PHP covers that through Composer, with Java on the server.

### Does Dompdf or mPDF support Flexbox and CSS Grid?

No. Dompdf documents that it supports neither, and mPDF's list of supported CSS includes neither. PD4ML supports both, and PD4ML 4.2 implements CSS Grid to the specification.

### Is PD4ML a good alternative to mPDF?

Yes, when you need modern CSS layout, PDF/UA, PDF/A-2 or PDF/A-4, digital signatures, or DOCX and RTF output, or when the GPL does not fit your product. mPDF remains simpler to deploy because it needs no Java.

### Do I need Java to use PD4ML in PHP?

Yes. PD4ML for PHP runs the PD4ML engine in a Java 8 or later process. On web servers you run one bridge server (`vendor/bin/pd4ml serve`) that all PHP requests share; Java starts once, and each conversion then takes milliseconds for an ordinary document.

### Can PHP create PDF/A and ZUGFeRD invoices from HTML?

Yes. PD4ML has presets for ZUGFeRD and Factur-X on PDF/A-3, including accessible PDF/A-3a invoices. mPDF can produce PDF/A-3b with associated files assembled by hand, and tc-lib-pdf offers a Factur-X workflow through its API.

### Can PHP convert HTML to Word (DOCX)?

Among these libraries, only PD4ML converts HTML and CSS to DOCX and RTF, from the same layout as the PDF.

### Is TCPDF still maintained?

TCPDF is in maintenance mode. Its author recommends tc-lib-pdf for new projects; TCPDF 7 is a compatibility layer on top of it.

## Try PD4ML for PHP

Install the module with Composer, run `vendor/bin/pd4ml install`, and convert one of your own templates. Unlicensed output carries a watermark, with all features enabled. See [PD4ML for PHP](https://pd4ml.com/docs/integrations/pd4ml-php.html), the [comparison with Java HTML-to-PDF libraries](https://pd4ml.com/docs/html-to-pdf-library-comparison.html), and [PD4ML editions and prices](https://pd4ml.com/products/).

*Product names are trademarks of their respective owners. Information about other libraries is taken from their public documentation as of November 2026 and may have changed; corrections are welcome through [PD4ML support](https://pd4ml.com/support-topics/). This page is not legal advice on open-source licenses.*
