Skip to main content
Back to packages
7,265 GitHub stars

barryvdh/laravel-dompdf

View on GitHub

Description

Laravel wrapper for Dompdf HTML to PDF Converter

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.

use Barryvdh\DomPDF\Facade\Pdf;
 
$pdf = Pdf::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

or use the App container:

$pdf = App::make('dompdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream();

Or use the facade:

You can chain the methods:

return Pdf::loadFile(public_path().'/myfile.html')->save('/path-to/my_stored_file.pdf')->stream('download.pdf');

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

Pdf::loadHTML($html)->setPaper('a4', 'landscape')->setWarnings(false)->save('myfile.pdf')

Recent Courses on Laravel Daily

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.