pdf-generation-from-html-view-laravel

PDF Generation From HTML View in Laravel 5.3

In large scale web application have generate pdf functionality. There are many third party plugins are available to generate pdf. Apart from all those plugins dompdf  is the best one. Following code explains how pdf generations is possible from html view with dynamic data.

step 1 : Installation

Open terminal and add below line of code.

step 2 : Add service provider and aliase

Open ‘config/app.php’ and add below code.

step 3 : Create table and model

Create model file name as app/States.php and copy below code.

step 4 : Routing (app/Http/routes.php)

step 5 : Controller

(app/Http/Controllers/PdfController.php)

step 6 : Views 

resources/views/export/index.blade.php

resources/views/export/pdfview.blade.php

Sample screen shorts :

generate-pdf-laravel

 

generate-pdf-laravel-2-png

  • Khadreal

    Did the same thing you did but my pdf is blank, any idea why.

    Thanks