dev-master
9999999-devLaravel snappy package
The Requires
- php >=5.3.0
- illuminate/support 4.x
- knplabs/knp-snappy *
by David Haska
laravel image pdf wkhtmltopdf snappy wkhtmltoimage
Wallogit.com
2017 © Pedro Peláez
Laravel snappy package
Provider:, (*1)
'Haska\Snappy\SnappyServiceProvider',
Alias:, (*2)
'PDF' => 'Haska\Snappy\Facades\SnappyPdf', 'Image' => 'Haska\Snappy\Facades\SnappyImage',
Config:, (*3)
php artisan config:publish haska/laravel-snappy
You can create a new Snappy PDF/Image instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download., (*4)
Using the App container:, (*5)
$snappy = App::make('snappy.pdf');
//To file
$snappy->generateFromHtml('<h1>Bill</h1><p>You owe me money, dude.</p>', '/tmp/bill-123.pdf');
$snappy->generate('http://www.github.com', '/tmp/github.pdf'));
//Or output:
return new Response(
$snappy->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
Using the wrapper:, (*6)
$pdf = App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->stream();
Or use the facade:, (*7)
$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');
You can chain the methods:, (*8)
return PDF::loadFile('http://www.github.com')->stream('github.pdf');
You can change the orientation and paper size, (*9)
PDF::loadHTML($html)->setPaper('a4')->setOrientation('landscape')->setOption('margin-bottom', 0)->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., (*10)
Laravel snappy package
laravel image pdf wkhtmltopdf snappy wkhtmltoimage