Laravel Dompdf

A Laravel service-provider wrapper around Dompdf for generating PDFs from HTML or Blade views.

Library
Composer
vv3.1.2
7,284stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
59/100Fair
Development Activity36
Maintenance24
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture72
Code Quality74
Innovation55
Learning Curve82

Laravel Dompdf integrates the Dompdf HTML-to-PDF renderer into Laravel as a first-class service, registering a PDF facade and a bound dompdf.wrapper container instance so you can render a Blade view, raw HTML string, or file straight into a downloadable, streamable, or saved PDF. It ships a publishable config file for Dompdf’s rendering options (paper size, fonts, remote-content policy, PDF/A compliance) and supports Laravel 9 through 13.

What You Get

  • A Pdf facade with loadView(), loadHTML(), and loadFile() entry points that return a chainable wrapper
  • stream(), download(), save(), and output() methods for the four common ways to deliver a generated PDF
  • A publishable config/dompdf.php file controlling paper size, fonts, DPI, remote-content access, and PDF/A-3b compliance
  • Support for embedding XML attachments (e.g. Zugferd/Factur-X electronic invoices) via addEmbeddedFile() and setAdditionalXmpRdf()

Common Use Cases

  • Rendering an invoice or receipt Blade view into a downloadable PDF for a customer
  • Streaming a generated PDF inline in the browser for print-preview style workflows
  • Producing PDF/A-3b compliant archival PDFs, including Factur-X/Zugferd electronic invoices with embedded XML
  • Batch-generating and saving PDF reports to storage from a scheduled Laravel job

Under The Hood

Architecture: ServiceProvider.php registers the package’s config, binds a dompdf.wrapper singleton backed by src/PDF.php into Laravel’s container, and exposes it through Facade/Pdf.php; PDF.php itself composes a Dompdf instance, an Illuminate Filesystem, a ConfigRepository, and a ViewFactory, translating Laravel-side config keys into Dompdf’s Options object and forwarding unknown method calls (setPaper, setCanvas, getDom, etc., declared via @method PHPDoc annotations) straight through to the underlying Dompdf object. Tech Stack: PHP 8.1+ targeting Laravel/Illuminate 9 through 13 as a peer dependency, built on dompdf/dompdf ^3.1 for the actual HTML/CSS-to-PDF rendering engine, using orchestra/testbench for package testing and larastan/php_codesniffer for static analysis and style enforcement. Code Quality: A tests/ directory (3 files) exercises the wrapper against Testbench’s in-memory Laravel app; the core PDF.php class is a single 387-line class that stays thin by delegating rendering to Dompdf and only adding Laravel-specific plumbing (view rendering, storage/file handling, HTTP response headers via Symfony’s HeaderUtils for downloads). API Design: The facade-based API (Pdf::loadView(…)->download()) is designed to feel like a native Laravel response builder, requiring only composer require and a config publish to start generating PDFs, with method chaining covering the load -> configure -> output lifecycle in one fluent expression.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search