DOM PDF integration in laravel 5

DOM PDF integration in laravel 5

In this tutorial we are going to see how to integrate PDF in laravel. We are going to integrate DOM PDF in laravel. DOMPDF is one of the most powerful tool for PDF converstion using php.

Just Follow below setps :

Step 1 :

Run the following commant in composer : composer require barryvdh/laravel-dompdf or add the follwing line in composer.json file and run composer update commant : “barryvdh/laravel-dompdf”: “0.6.*”

Step 2 :

Add the following line in service provider array in config/app.php  : Barryvdh\DomPDF\ServiceProvider::class,

Step 3 :

Add follwing alias in the same file. : ‘PDF’ => Barryvdh\DomPDF\Facade::class,

Step 4 :

Add the following lines to register provider in bootstrap/app.php : $app->register(\Barryvdh\DomPDF\ServiceProvider::class);

Step 5 :

To change the configuration, copy the config file to your config folder and enable it in bootstrap/app.php:  $app->configure(‘dompdf’);

How to Use :

You can create a new DOMPDF instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download.

Or use the facade:

You can chain the methods:

You can change the orientation and paper size, and hide or show errors (by default, errors are shown when debug is on)

Tip: UTF-8 support

In your templates, set the UTF-8 Metatag:

Tip: Page breaks

You can use the CSS page-break-before/page-break-after properties to create a new page.

For More Please Visit :