Laravel 6 Generate PDF File Tutorial
https://www.itsolutionstuff.com/post/laravel-6-generate-pdf-file-tutorialexample.html
Last updated
https://www.itsolutionstuff.com/post/laravel-6-generate-pdf-file-tutorialexample.html
Last updated
By Hardik Savani September 11, 2019 Category : LaravelPauseUnmuteLoaded: 3.41%FullscreenHere, I will explain how to generate pdf file and download in laravel 6. i will explain step by step creating pdf file with laravel 6 using dompdf package. using dompdf package we can generate pdf file from view or html blade file in laravel 6.
As you know, few days ago laravel 6 released. so i plan to add tutorial for creating pdf file with laravel 6.
PDF is one of basic requirement when you are working with erp level project or e commerce website. we may need to create pdf file for report or invoice etc. So, here i will give you very simple example for create pdf file with laravel.
You need to just follow bellow step to create pdf file and also can download. So let's do bellow steps.
Step 1: Install Laravel 6
I am going to explain step by step from scratch so, we need to get fresh Laravel 6 application using bellow command, So open your terminal OR command prompt and run bellow command:
Step 2: Install dompdf Package
first of all we will install barryvdh/laravel-dompdf composer package by following composer command in your laravel 6 application.
After successfully install package, open config/app.php file and add service provider and alias.
config/app.php
Read Also: Laravel 6 Release New Features and Upgrade
Step 3: Add Route
In this is step we need to create routes for items listing. so open your "routes/web.php" file and add following route.
routes/web.php
Step 4: Add Controller
Here,we require to create new controller PDFController that will manage generatePDF method of route. So let's put bellow code.
app/Http/Controllers/PDFController.php
Step 5: Create View File
In Last step, let's create myPDF.blade.php(resources/views/myPDF.blade.php) for layout of pdf file and put following code:
resources/views/myPDF.blade.php
Read Also: Laravel 6 Ajax Form Validation Tutorial
Now we are ready to run this example and check it...
I hope it can help you...