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
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Laravel 13 Starter Kit Teams and Customizations
10 lessons
33 min
Testing in Laravel 13 For Beginners
26 lessons
1 h 41 min read