dompdf: HTML to PDF converter for PHP
CSS 2.1 compliant HTML layout and rendering engine.
Learn more about Dompdf
dompdf is a PHP library that implements an HTML layout and rendering engine capable of converting HTML and CSS to PDF documents. It parses CSS 2.1 and some CSS3 properties, handles complex table layouts, and embeds fonts and images directly into the generated PDF. The library uses the R&OS PDF class internally, eliminating dependencies on external PDF generation tools. Common use cases include generating invoices, reports, and documents from web content in server-side PHP applications.
CSS-Driven PDF Rendering
Converts HTML to PDF using standard CSS 2.1 properties and select CSS3 features. Style documents with external stylesheets, inline styles, or element attributes—no proprietary markup or PDF-specific syntax required.
Embedded Font Support
Includes DejaVu fonts for Unicode coverage and supports custom TrueType font embedding. Handles multilingual content and special characters beyond standard PDF fonts limited to Windows ANSI encoding.
Zero External Dependencies
Runs entirely within PHP without requiring external binaries like wkhtmltopdf or PhantomJS. This pure PHP implementation simplifies deployment across hosting environments and eliminates compatibility issues with system libraries or server configurations.
<?php
require_once 'vendor/autoload.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>Invoice #12345</h1><p>Total: $499.99</p>');
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream('invoice.pdf');Fix stylesheet-related issues with data URI parsing and base stylesheet retrieval
- –Address issue parsing data URIs in stylesheets
- –Address issue retrieving base stylesheet when filegetcontents used before rendering
Fix timing of fixed-position element insertion to improve rendering behavior
- –Moves fixed-position element insertion before page reflow callback
Fix font selection logic issue introduced in version 3.1.1
- –Fixes issue with the font selection logic introduced in release 3.1.1
See how people are using Dompdf
Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
n
A command-line utility for installing, switching between, and managing multiple Node.js versions on Unix-like systems.
PowerShell
Cross-platform shell and scripting language for system administration with structured data support.
plotly.py
Interactive browser-based charts from Python with declarative API.
Gson
Reflection-based Java library for JSON object conversion.
Floki
Elixir HTML parser with CSS selectors and multiple parser backends.