Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
HTML to PDF converter for PHP with CSS 2.1 support.
Dompdf is an open-source PHP library that converts HTML documents into PDF files using its own HTML layout and rendering engine, which is mostly compliant with CSS 2.1. It accepts HTML with embedded or external stylesheets as input and produces a rendered PDF file, running on any PHP 7.1+ server with the DOM, MBString, and GD extensions installed.
Dompdf is a style-driven HTML-to-PDF converter written in PHP and distributed as the dompdf/dompdf Composer package from its GitHub repository. It parses external stylesheets, inline style tags, and per-element style attributes, applies most presentational HTML 4.0 attributes, and generates the PDF internally with the bundled R&OS PDF class, so no external PDF library is required. The project ships with DejaVu Sans, DejaVu Serif, and DejaVu Sans Mono fonts (version 2.34) pre-installed to give Unicode character coverage beyond the five built-in PDF fonts (Helvetica, Times-Roman, Courier, Zapf-Dingbats, Symbol).
@import, @media, and @page rules for print-specific styling.loadHtml, render, and stream, choosing paper size and orientation with setPaper.@page and @media CSS rules to control page size, margins, and print-only styles.The Quick Start flow is a four-step process: instantiate the Dompdf class, pass HTML to loadHtml, optionally call setPaper (for example A4 landscape), then call render() and stream() to output the PDF to the browser. Configuration options — such as defaultFont, isRemoteEnabled, and the chroot directory restriction — are set through the Options class at instantiation or at runtime via setOptions.
isRemoteEnabled option plus curl or allow_url_fopen; local files must fall inside the configured chroot path.Dompdf converts HTML documents into PDF files using a PHP-based CSS 2.1-compliant rendering engine. It supports stylesheets, complex tables, GIF/PNG/BMP/JPEG images, basic SVG, and inline PHP, and can stream the finished PDF to a browser or save it.
Dompdf requires PHP 7.1 or higher, the DOM and MBString extensions, the php-font-lib and php-svg-lib libraries, and GD for image processing. The IMagick or GMagick extensions optionally improve image processing performance for certain image types.
The standard installation is Composer: run composer require dompdf/dompdf and load the vendor autoloader. Packaged releases are also downloadable from the GitHub releases page (filenames like dompdf_1-0-0.zip), and the repository can be cloned with git along with its dependency libraries.
Yes, through the bundled DejaVu fonts. Reference a font such as DejaVu Sans in your CSS to display characters outside Windows ANSI encoding, or supply custom TrueType fonts via @font-face rules for embedding in the output PDF.
Yes, Dompdf is open source and freely available from GitHub and Packagist; the repository has over 11,000 GitHub stars. The project accepts optional PayPal donations to fund further development.
