Laravel Dompdf
A Laravel service-provider wrapper around Dompdf for generating PDFs from HTML or Blade views.
Repository Health
Technical Analysis
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.
Used by 5 apps in this directory
Akaunting
Invoicing Finance
Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.
Bagisto
Analytics · Ecommerce
Open-source Laravel eCommerce platform for building multi-vendor marketplaces, B2B stores, headless commerce, and AI-powered storefronts.
Crater
Invoicing Finance
Open source invoicing and billing platform for freelancers and small businesses — create estimates, track expenses, accept Stripe payments, and run recurring invoices from your own server.
Hi.Events
Ecommerce · Scheduling
Self-hosted event ticketing platform that keeps your attendee data, brand, and revenue completely under your control.
Krayin CRM
Ecommerce · CRM
Free, open-source Laravel & Vue.js CRM for SMEs and enterprises to manage the complete customer lifecycle.