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


step 6 : Views 



Sample screen shorts :




  • Khadreal

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