DEV Community


Posted on • Originally published at


How To Generate PDF Using DomPDF In Laravel 9

In this article, we will see how to generate pdf using dompdf in laravel 9. For generating pdf files we will use the laravel-dompdf package. It creates a pdf file and also provides download file functionalities.

It is very easy to generate pdf files in laravel 9. we will see an example of a very simple way to generate a pdf file and download it to your system.

Using barryvdh/laravel-dompdf pdf you can create a new DomPDF instance and load an HTML string, file or view name.

You can save it to a file, or show it in the browser or download it. Also, you can generate pdf from HTML view in laravel 9.

So, let's see laravel 9 generates a pdf file using dompdf.

How To Generate PDF In Laravel 9 Using DomPDF

Step 1: Install Laravel 9 To Create PDF In Laravel 9

Step 2: Install barryvdh/laravel-dompdf Package

Step 3: Create Controller

Step 4: Add Route

Step 5: Create Blade File

Step 6: Run the Laravel 9 DomPDF Application
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.