Create a dynamic pdf in Laravel, Here I would like to share with you how to create a dynamic PDF file in Laravel. Making a dynamic pdf file is required in many situations like create an invoice , create a report and many more things.
Here in this article we will use Laravel DomPDF Library to generate a dynamic PDF Library.
Follow the below given steps to generate or create pdf in laravel.
1.Install Laravel App2.Setup Database3.Install laravel-dompdf Package4.Make Route5.Create Controller6.Create Blade view for Generate Pdf7.Run Project
####### 1. Install Laravel App.
I assume Laravel is already installed, if not follow below link to installation Laravel app
####### 2. Setup Database.
After successfully download Laravel Application,Open your project .env file and set up database credential .
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_demo
DB_USERNAME=root
DB_PASSWORD=
####### 3. Download Laravel Dompdf Package.
To create PDF file in Laravel first of all we have to download laravel-dompdf package.
composer require barryvdh/laravel-dompdf
After successfully install the laravel dompdf package, open the config/app.php and add the providers and aliases :
'providers' => [
Barryvdh\DomPDF\ServiceProvider::class,
],
'aliases' => [
'PDF' => Barryvdh\DomPDF\Facade::class,
]
#laravel