explaingit

barryvdh/laravel-dompdf

7,264PHPAudience · developerComplexity · 2/5Setup · easy

TLDR

A Laravel package that converts HTML templates into downloadable PDF files using Dompdf, letting you generate, stream, or save PDFs with just a few lines of PHP code.

Mindmap

mindmap
  root((laravel-dompdf))
    What it does
      HTML to PDF
      Stream or download
      Save to disk
    Configuration
      Paper size and DPI
      Font control
      Remote image loading
    PDF/A-3b support
      Long-term archiving
      Embedded XML
      E-invoicing standards
    Tech
      PHP and Laravel
      Dompdf library
      Composer install
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate a PDF invoice from a Laravel Blade template and trigger a browser download.

USE CASE 2

Create PDF/A-3b files with embedded XML for electronic invoicing standards like Zugferd or Factur-X.

USE CASE 3

Save generated PDFs to disk for later retrieval or email attachment.

USE CASE 4

Stream a PDF directly to the browser so users can view it without downloading.

Tech stack

PHPLaravelDompdfComposer

Getting it running

Difficulty · easy Time to first run · 30min

Requires an existing Laravel or Lumen project, install via Composer and publish the config file.

In plain English

This package connects Laravel, a popular PHP web framework, to Dompdf, a library that converts HTML into PDF files. The result is that Laravel developers can generate downloadable PDFs directly from their application's HTML templates without needing a separate PDF service or external API. The basic workflow is straightforward: you point the package at a Laravel view, which is an HTML template with data filled in, and it renders that view as a PDF. From there you can send the PDF directly to the browser for the user to view, trigger a file download, or save it to disk. A few lines of PHP code are enough to get started, and all major actions can be chained together in a single expression. Configuration options let you adjust paper size and orientation, set the resolution in DPI, control which fonts are used, and enable or disable features like remote image loading and JavaScript processing within the HTML. Remote access is turned off by default since version 3 for security reasons. Settings can be applied globally through a config file or changed individually for each PDF at runtime. The package also supports generating PDF/A-3b files, which is a stricter format designed for long-term archiving. This includes support for embedding XML attachments inside the PDF, which is required for electronic invoicing standards like Zugferd and Factur-X. Generating these compliant PDFs requires using embeddable fonts rather than the built-in core PDF fonts. For practical formatting, the package relies on standard CSS features already built into Dompdf: page breaks can be inserted between sections using the CSS page-break-after property, and UTF-8 character encoding is supported by including the appropriate meta tag in the HTML template. The package is installed via Composer and works with both full Laravel and the lighter Lumen variant of the framework.

Copy-paste prompts

Prompt 1
Using barryvdh/laravel-dompdf, write a controller method that loads a Blade view called 'invoice' with order data and returns it as a PDF file download.
Prompt 2
How do I configure laravel-dompdf to use a custom font so that my PDF correctly renders Arabic or Chinese characters?
Prompt 3
Write a Laravel route that generates a PDF/A-3b file with an embedded XML attachment for Factur-X electronic invoicing compliance.
Prompt 4
How do I override the default paper size to A4 landscape and enable remote image loading for a single laravel-dompdf call at runtime?
Open on GitHub → Explain another repo

← barryvdh on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.