How to create html template and generate PDF in laravel 5.8
Laravel 5.8 - How to Generate HTML to PDF with Laravel domPDF
In this post, we are going to learn about how to generate PDF in laravel 5.8 where i am using a simple html template to convert into PDF in laravel 5.8.
To generate HTML to PDF with laravel-domPDF, I am using a package called barryvdh/laravel-dompdf
So, Let's get started:
Step 1: Download or install the laravel 5.8 version using the following command:
Step 2: Now, we have to install the package laravel-dompdf Package with the following command:
After installing the laravel-dompdf package successfully, setup with below steps.
Step 3: Open the app.php file in the following path: config/app.php. Add service provider and alias as shown below:
Step 4: Create a Controller named as PdfgenerateController using the following command:
After creating the controller successfully, paste the below code in the PdfgenerateController.php
Step 5: Let's create a route to generate the pdf and connect with the above created Controller as shown below:
Step 6: Final step, now we will create a file named yourPDF.blade.php in the following path: resource/views/yourPDF.blade.php and put the following code:
Thanks for reading..
© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT