Skip to content
Researched developer tool comparisonsPrices dated · vendor sources linked · no star ratings
Search

Stage 01 · Write · Researched comparison

Best PHP PDF Libraries in 2026

mPDF is the first pick for most teams that need HTML and CSS to PDF with good Unicode and RTL support, all in pure PHP. Pick Dompdf if you want a lighter HTML-to-PDF renderer with a simple Composer install. Pick TCPDF if you need fine control over low-level PDF features or you maintain an older codebase that already depends on it.

By
Published 27 Nov 2026 · 7 tools compared

We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.

Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.

Key takeaways

  • mPDF, Dompdf, TCPDF and FPDF are pure PHP libraries that install with Composer and need no external binaries.
  • Snappy and Browsershot render HTML through an external engine, so they need wkhtmltopdf or headless Chrome on the host.
  • Every library here is free and open source, so cost is not the deciding factor; engine dependencies and CSS support are.
  • smalot/pdfparser reads and extracts PDF content but does not create PDFs, so pair it with a generator.

Who each pick is for

  • HTML and CSS to PDF with Unicode and RTL textmPDF
  • Lightweight HTML to PDF rendering in pure PHPDompdf
  • Low-level PDF control and legacy PHP codebasesTCPDF
  • Small, dependency-free PDFs built from codeFPDF and FPDI
  • HTML to PDF through the wkhtmltopdf binarySnappy
  • PDF output that matches modern browser renderingBrowsershot
  • Reading and extracting text and metadata from PDFssmalot/pdfparser

Comparison

The 7 tools at a glance
ToolBest forStandout featureListed starting priceFree plan or trial
1mPDFHTML and CSS to PDF with Unicode and RTL textStrong CSS and page-layout supportFree (open source)Free plan
2DompdfLightweight HTML to PDF rendering in pure PHPSimple Composer installFree (open source)Free plan
3TCPDFLow-level PDF control and legacy PHP codebasesLarge feature set with fine control over PDF structureFree (open source)Free plan
4FPDF and FPDISmall, dependency-free PDFs built from codeVery small footprintFree (open source)Free plan
5SnappyHTML to PDF through the wkhtmltopdf binaryRenders real HTML and CSS through an external engineFree (open source)Free plan
6BrowsershotPDF output that matches modern browser renderingUses headless Chrome, so modern CSS and JavaScript workFree (open source)Free plan
7smalot/pdfparserReading and extracting text and metadata from PDFsPure PHP with no external binariesFree (open source)Free plan

How we picked

We compared libraries on fit for common PHP PDF jobs, supported platforms and dependencies, licence and price, and the main limits each one documents. We also looked at whether a library generates or reads PDFs, since those are different tasks. Sources are vendor pages, project documentation and public repositories. Prices and licences can change, so confirm details on the vendor or repository page before you commit.

The tools, one by one

01

mPDF

Best for hTML and CSS to PDF with Unicode and RTL text

Visit mpdf.github.io
mPDF homepage
mPDF homepage, captured Nov 2026

What it is and where it fits

mPDF converts HTML and CSS into PDF files in pure PHP. It supports page headers and footers, page breaks, tables, columns and a wide range of CSS properties. It handles UTF-8 and non-Latin scripts, including Arabic and Hebrew, which many simpler libraries struggle with. It installs with Composer and needs no external binary.

The library is maintained on GitHub under the GPL and is free to use. Its main limits are memory and speed: very large documents or complex tables can hit PHP memory limits, and rendering is slower than lighter engines. It suits applications that need styled HTML output with international text. Teams with tight memory budgets or simple text-only PDFs may prefer a lighter option.

Standout: Strong CSS and page-layout support

Pricing pointer

Free (open source), as listed by the vendor (mPDF website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Strong CSS and page-layout support
  • handles Unicode, CJK and right-to-left scripts

Drawbacks

  • Memory use grows on large documents
  • slower than Dompdf on simple pages

Skip it if this limit matters to you: memory use grows on large documents.

Verdict. A sensible pick for HTML and CSS to PDF with Unicode and RTL text.

Alternatives in this guide: Dompdf, TCPDF, FPDF and FPDI

02

Dompdf

Best for lightweight HTML to PDF rendering in pure PHP

Visit github.com
Dompdf homepage
Dompdf homepage, captured Nov 2026

What it is and where it fits

Dompdf is a pure PHP HTML-to-PDF renderer. It reads an HTML document and a stylesheet and produces a PDF, with support for tables, floats, page breaks and basic CSS. It is widely used in frameworks such as Laravel through wrapper packages. It installs with Composer and runs anywhere PHP runs, with no external binary.

The project is open source under the LGPL and free to use. Its CSS support is closer to CSS 2.1 than to modern CSS, so flexbox and grid layouts do not render as they would in a browser. JavaScript is not executed. It suits invoices, reports and simple documents. Teams that need modern CSS layouts should look at a headless-browser approach instead.

Standout: Simple Composer install

Pricing pointer

Free (open source), as listed by the vendor (Dompdf website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Simple Composer install
  • good CSS 2.1 support for common layouts

Drawbacks

  • Limited CSS3 and JavaScript support
  • large tables can be slow

Skip it if this limit matters to you: limited CSS3 and JavaScript support.

Verdict. A sensible pick for lightweight HTML to PDF rendering in pure PHP.

Alternatives in this guide: mPDF, TCPDF, FPDF and FPDI

03

TCPDF

Best for low-level PDF control and legacy PHP codebases

Visit tcpdf.org
TCPDF homepage
TCPDF homepage, captured Nov 2026

What it is and where it fits

TCPDF is one of the older PHP PDF libraries and remains widely used. It gives direct control over pages, fonts, barcodes, images and document metadata. It supports many languages and font formats, and it can produce PDF/A and other structured output. It installs with Composer or as a standalone package.

TCPDF is free and open source under the LGPL. Its API is procedural and older in style, and its HTML support is more limited than mPDF or Dompdf, so complex CSS does not render well. It suits projects that need low-level control or that already depend on it. New projects that mainly need HTML-to-PDF should compare it against mPDF first.

Standout: Large feature set with fine control over PDF structure

Pricing pointer

Free (open source), as listed by the vendor (TCPDF website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Large feature set with fine control over PDF structure
  • barcode and font support built in

Drawbacks

  • Older API
  • HTML and CSS support is weaker than mPDF or Dompdf

Skip it if this limit matters to you: older API.

Verdict. A sensible pick for low-level PDF control and legacy PHP codebases.

Alternatives in this guide: mPDF, Dompdf, FPDF and FPDI

04

FPDF and FPDI

Best for small, dependency-free PDFs built from code

Visit fpdf.org
FAFPDF and FPDIfpdf.org
Homepage screenshot not available; visit the vendor site.

What it is and where it fits

FPDF is a minimal PHP class for building PDFs from code. You call methods to add pages, set fonts and write text, lines and images. It has no HTML parser and no CSS engine, so you position content yourself. FPDI is a companion library that imports existing PDF pages into an FPDF document, which is useful for templates and overlays.

FPDF is free and open source under a permissive licence. Its small size and lack of dependencies make it easy to deploy. The trade-off is that anything beyond simple text layout has to be coded by hand, and UTF-8 text needs extra font setup. It suits fixed-layout documents such as labels, tickets and simple certificates. Teams that need HTML rendering should use mPDF or Dompdf instead.

Standout: Very small footprint

Pricing pointer

Free (open source), as listed by the vendor (FPDF and FPDI website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Very small footprint
  • simple API for drawing text and shapes

Drawbacks

  • No HTML or CSS rendering
  • UTF-8 needs extra work

Skip it if this limit matters to you: no HTML or CSS rendering.

Verdict. A sensible pick for small, dependency-free PDFs built from code.

Alternatives in this guide: mPDF, Dompdf, TCPDF

05

Snappy

Best for hTML to PDF through the wkhtmltopdf binary

Visit github.com
Snappy homepage
Snappy homepage, captured Nov 2026

What it is and where it fits

Snappy is a PHP wrapper around the wkhtmltopdf command-line tool. You pass it HTML or a URL, and it runs wkhtmltopdf to produce a PDF. Because rendering happens in an external engine, CSS support is broader than in pure PHP libraries, and it can render full web pages. It installs with Composer, but the wkhtmltopdf binary must be installed and available on the server.

Snappy is free and open source. The main limits come from wkhtmltopdf itself: it uses an old WebKit engine, so modern CSS features may not render correctly, and the binary adds a deployment dependency. It suits teams that already run wkhtmltopdf or need to render existing web pages. Projects that need current browser rendering should compare it with Browsershot.

Standout: Renders real HTML and CSS through an external engine

Pricing pointer

Free (open source), as listed by the vendor (Snappy website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Renders real HTML and CSS through an external engine
  • supports headers and footers

Drawbacks

  • Requires the wkhtmltopdf binary on the host
  • wkhtmltopdf uses an old WebKit engine

Skip it if this limit matters to you: requires the wkhtmltopdf binary on the host.

Verdict. A sensible pick for HTML to PDF through the wkhtmltopdf binary.

Alternatives in this guide: mPDF, Dompdf, TCPDF

06

Browsershot

Best for pDF output that matches modern browser rendering

Visit github.com
Browsershot homepage
Browsershot homepage, captured Nov 2026

What it is and where it fits

Browsershot is a PHP package from Spatie that drives headless Chrome through Puppeteer. You give it a URL or HTML, and it renders the page in Chrome and saves it as a PDF. Because it uses a current browser engine, modern CSS and JavaScript-driven pages render as they do in Chrome. It installs with Composer and needs Node.js plus a Chrome or Chromium binary on the host.

Browsershot is free and open source. The cost is operational: it needs Node.js, a browser binary and more memory and CPU than pure PHP libraries. Startup time per render is also higher. It suits teams that need pixel-accurate output from existing web pages or modern CSS. Small servers or shared hosting may not be able to run it.

Standout: Uses headless Chrome, so modern CSS and JavaScript work

Pricing pointer

Free (open source), as listed by the vendor (Browsershot website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Uses headless Chrome, so modern CSS and JavaScript work
  • good control over page size and margins

Drawbacks

  • Requires Node.js and a headless Chrome install
  • heavier resource use than pure PHP libraries

Skip it if this limit matters to you: requires Node.js and a headless Chrome install.

Verdict. A sensible pick for PDF output that matches modern browser rendering.

Alternatives in this guide: mPDF, Dompdf, TCPDF

07

smalot/pdfparser

Best for reading and extracting text and metadata from PDFs

Visit github.com
smalot/pdfparser homepage
smalot/pdfparser homepage, captured Nov 2026

What it is and where it fits

smalot/pdfparser is a pure PHP library for reading PDF files. It parses a PDF and exposes its pages, text, metadata and some structural details. Common uses include extracting text for search or indexing, reading form fields and pulling document properties. It installs with Composer and needs no external tools.

The library is free and open source under the MIT licence. It does not generate PDFs, so it is a complement to a generator rather than a replacement. Text extraction can be imperfect on scanned documents or PDFs with unusual encoding, and it does not perform OCR. It suits backend jobs that need to read uploaded PDFs. Teams that need OCR should add a separate OCR step.

Standout: Pure PHP with no external binaries

Pricing pointer

Free (open source), as listed by the vendor (smalot/pdfparser website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Pure PHP with no external binaries
  • extracts text and document metadata

Drawbacks

  • Does not create PDFs
  • extraction quality varies with PDF structure

Skip it if this limit matters to you: does not create PDFs.

Verdict. A sensible pick for reading and extracting text and metadata from PDFs.

Alternatives in this guide: mPDF, Dompdf, TCPDF

Who should use what

If you need styled HTML invoices with Unicode and RTL text, start with mPDF. If you want a lightweight pure PHP renderer for simple documents, use Dompdf. If you need output that matches modern browser rendering and can run Node.js and Chrome, use Browsershot. If you only need to read uploaded PDFs and extract text, use smalot/pdfparser alongside whichever generator you pick.

Questions to settle before you buy

What to check before you buy

  • Confirm the library runs in pure PHP or check which external binaries your host allows.
  • Test your real templates, fonts and languages, especially non-Latin scripts and right-to-left text.
  • Measure memory and render time on your largest expected document.
  • Check the licence against your project's distribution requirements.
  • Confirm the project is still maintained by checking recent commits and releases.

FAQ

Do I need an external binary to generate PDFs in PHP?

No. mPDF, Dompdf, TCPDF and FPDF are pure PHP and need no external binary. Snappy needs wkhtmltopdf, and Browsershot needs Node.js and a Chrome or Chromium binary. Pure PHP libraries are easier to deploy on shared hosting.

Which PHP PDF library has the best CSS support?

Browsershot, because it renders through headless Chrome and supports modern CSS and JavaScript. Among pure PHP libraries, mPDF has the broadest CSS support, followed by Dompdf. None of the pure PHP libraries match a current browser engine for modern layout features.

Can these libraries read PDFs as well as create them?

Only smalot/pdfparser is built for reading. The others generate PDFs. FPDI can import existing PDF pages into an FPDF document, which is useful for templates, but it is not a general text-extraction tool. Pair a generator with pdfparser if you need both.

Are these PHP PDF libraries free?

Yes. All the libraries listed here are free and open source under licences such as MIT, LGPL or GPL. Check the specific licence before distributing or modifying the code, since the terms differ between projects.

Can I generate PDFs from HTML with PHP?

Yes. mPDF, Dompdf, Snappy and Browsershot all accept HTML input. mPDF and Dompdf parse HTML and CSS in PHP. Snappy and Browsershot render HTML through an external engine, which gives broader CSS support but adds deployment dependencies.

Sources we checked

Method: how we score · editorial policy.

  1. mPDF (official site)
  2. Dompdf (official site)
  3. TCPDF (official site)
  4. FPDF and FPDI (official site)
  5. Snappy (official site)
  6. Browsershot (official site)
  7. smalot/pdfparser (official site)

Change log. First published 27 Nov 2026.