PHP PDF Libraries Compared

How tc-lib-pdf compares with TCPDF, FPDF, mPDF, Dompdf, and the headless-browser renderers

A feature comparison of the PDF tools most often used from PHP. For the full tc-lib-pdf capability index, see /features/ .

Two classes of tool are compared separately, because they solve different problems: libraries that write PDF from PHP, and renderers that drive a browser engine and return its print output.

Versions, licences, and PHP requirements come from Packagist. Capabilities come from each project’s own documentation and source, cover what the package itself provides without third-party extensions, and were checked on 2026-08-31. Corrections are welcome: open an issue on tc-lib-pdf .

Packages

PackageVersionPHPLicenceApproach
tc-lib-pdf8.73^8.2LGPL-3.0-or-laterTyped document API over a stack of focused packages
TCPDF (legacy)7.0>=8.2LGPL-3.0-or-laterSingle-class library (Deprecated)
FPDF1.9none declaredPermissive, no attribution clauseMinimal primitive drawing and text
mPDF8.3^5.6 to ~8.5GPL-2.0-onlyHTML and CSS to PDF, FPDF-derived core
Dompdf3.1^7.1 || ^8.0LGPL-2.1CSS 2.1 layout engine in PHP
HTML2PDF5.3^7.2 || ^8.0OSL-3.0HTML front end built on legacy TCPDF
FPDI2.6>=7.2MITPage import add-on for FPDF, TCPDF, and others

Capabilities

The legacy TCPDF is left out below: it is deprecated and not a candidate for new projects, so comparing against it would say nothing useful. HTML2PDF is left out for the same reason, since it wraps that codebase. FPDI is an import add-on rather than a generator, so it appears only in the import row.

Capabilitytc-lib-pdfmPDFDompdfFPDF
Font formatsTrueType, OpenType with TrueType outlines, Type1, CID-0, coreTrueType, TrueType collections, OpenType with TrueType outlinesTrueType and Type1; OpenType unreliable, CFF outlines unsupportedcore fonts, TrueType and Type1 in single-byte encodings
Font embeddingfull embedding, subsetting, or neitherembedding and subsettingembedding and subsetting, unreliable for OpenTypeembedding, no subsetting
Unicode textfull, Unicode 17 data, Identity-H with generated ToUnicode CMapsfullfull, with the bundled DejaVu fontsonly through the tFPDF fork
Characters above the BMPwith fonts converted for the full cmap subtableall planes, with a less compact embeddingnono
Bidirectional textUAX #9, validated against the official conformance suite; rule L3 not implementedyes, with OTL enablednono
Complex-script shapingArabic by Joining_Type, Devanagari reordering, Hangul compositionOpenType Layout (GSUB and GPOS), font drivennono
HTML and CSSwide subset: cascade and shorthands, selector combinators, pseudo-classes and pseudo-elements, floats and positioning, table layout, paged media, form controls mapped to widgetswide subset, parts of CSS3CSS 2.1, parts of CSS3no
CSS flexbox and gridnononono
SVGpaths, markers, text anchoring, style inheritancegradients, clip paths and use; no filters, markers or patternsbasic, through php-svg-libno
Barcodeslinear and postal families, plus Aztec, Datamatrix, PDF417 and QR Codelinear and postal; QR needs mpdf/qrcodenono
PDF/Aparts 1, 2 and 3, at levels a, b and uA-1b and A-3bnono
PDF/XX-1a, X-3, X-4 and X-5X-1anono
PDF/UA, tagged outputUA-1 and UA-2nonono
Factur-X, ZUGFeRD, Order-Xall four profiles, XMP extension schema written for youattach the file and hand-build the XMP RDF yourselfnono
Digital signaturesdetached CMS, plus PAdES B-B to B-LTAnonono
RFC 3161 timestampsverified before embeddingnonono
LTV validation materialDSS and VRI, with OCSP and CRL each validatednonono
Signing with an external keytwo-phase, for HSM and remote keysnonono
EncryptionRC4-40, RC4-128, AES-128, AES-256 R5 and R6RC4-40 and RC4-128RC4, through the CPDF adapterno
Import existing PDF pagesbuilt in, with box selection and N-up placementthrough FPDInothrough FPDI
Reproducible byte outputdates and file identifier pinnablenonono
Typed enums for optionsacross the whole package stacknonono
External runtime dependencynonenonenonenone

Renderers That Delegate to a Browser

The following are not PHP PDF libraries: none of them writes a PDF in PHP. Each is a Composer package that you call from PHP and that hands the work to a program outside it. They are here because they are what a team weighs a library against when the document starts as HTML.

PackageVersionLicenceWhat produces the PDF
Browsershot5.4MITChromium, through Node and Puppeteer, spawned as a child process
Snappy1.7MITthe wkhtmltopdf binary, spawned as a child process
Gotenberg PHP2.25MITa Gotenberg HTTP service running Chromium and LibreOffice

They are the right answer when the document is a web page and the layout depends on modern CSS. What you take on in exchange:

  • A browser engine to install, patch, and keep running next to the application, or a service to operate and reach over the network.
  • Output that changes when the engine updates, which rules them out where the same input has to produce the same bytes.
  • Little control over the PDF itself. Conformance modes, signatures, spot colours, and page boxes are either absent or bolted on afterwards with a second tool.
  • wkhtmltopdf specifically was archived upstream in January 2023 and renders with Qt WebKit, which predates most of CSS3.

A common arrangement is to use a renderer for marketing collateral and a library for the documents that carry legal or archival weight.