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');Patch release fixing data URI parsing in stylesheets and base stylesheet retrieval when file_get_contents is called before rendering.
- –Update if you embed data URIs in CSS or encounter stylesheet parsing errors after upgrade to v3.1.x.
- –Apply this fix if file_get_contents usage before render() causes missing base styles in your documents.
Patch release fixes timing of fixed-position element insertion to occur before page reflow callbacks.
- –Update if you rely on page reflow callbacks, as fixed-position elements now render earlier in the layout cycle.
- –No breaking changes or new requirements are documented in the release notes.
Patches a font selection regression introduced in v3.1.1; no breaking changes or new requirements.
- –Upgrade from v3.1.1 to resolve font selection logic errors that may cause incorrect font rendering.
- –Release notes do not specify the exact nature of the font selection bug or affected font families.
Top in Backend & APIs
Related Repositories
Discover similar tools and frameworks used by developers
express
Middleware-based HTTP routing and response handling for Node.js.
laravel
Full-stack PHP framework with ORM and dependency injection.
whatsmeow
Go client library for WhatsApp web multidevice protocol.
gson
Reflection-based Java library for JSON object conversion.
beego
MVC framework for Go with integrated ORM and routing.