haskadavid / laravel-pdf by haska

Laravel Pdf package
45
3
2
Package Data
Maintainer Username: haska
Maintainer Contact: david.haska@seznam.cz (David Haska)
Package Create Date: 2014-05-24
Package Last Update: 2014-09-29
Language: PHP
License: MIT
Last Refreshed: 2025-01-02 03:04:47
Package Statistics
Total Downloads: 45
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 2
Total Forks: 1
Total Open Issues: 0

Laravel pdf package

Informations

Provider:

'Haska\Pdf\PdfServiceProvider',

Alias:

'PDF' => 'Haska\Pdf\Facade',

Config:

php artisan config:publish haska/laravel-pdf

DOMPDF Wrapper for Laravel 4

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.

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

Or use the facade:

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

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')->setOrientation('landscape')->setWarnings(false)->save('myfile.pdf')

If you need the output as a string, you can get the rendered PDF with the output() function, so you can save/output it yourself.

Tip: UTF-8 support

In your templates, set the UTF-8 Metatag:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>