This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

A Dompdf Wrapper for Laravel.

dev-master 2016-04-19 20:25 UTC

This package is auto-updated.

Last update: 2021-11-19 03:30:07 UTC


A Dompdf Wrapper for Laravel 5.


Insert "stevebauman/pdf": "1.0.*" into your composer.json file:

"require": {
  "stevebauman/pdf": "1.0.*"

Then run composer update.

Next, add the service provider to your config/app.php file:


Run php artisan vendor:publish --tag="pdf"

Inside the published PDF configuration file (located in config/pdf.php), there are a couple paths you will need to make sure exist before you generate PDF's. You will most likely need to create these folders manually, or you will receive exceptions upon the generation of PDFs.

'font_dir' => storage_path('pdf/fonts'),

'font_cache' => storage_path('pdf/fonts'),

'temp_dir' => storage_path('pdf/tmp'),


Instantiate using the facade (Stevebauman\Pdf\Facades\Pdf), or using app('pdf'):

use Stevebauman\Pdf\Facades\Pdf;

class PdfController extends Conrtroller
    public function index()
        $pdf = app('pdf');

        // Or...

        $pdf = Pdf::getFacadeRoot(); // Returns a new instance of Dompdf.

        $data = ['...'];

        $html = view('pdf.index', compact('data'))->render();


        // Set the PDF paper type.
        $pdf->setPaper('A4', 'landscape');

        // Render the specified HTML.

        // Output the generated PDF to Browser.

For detailed usage, please visit the Dompdf Repository.