2017 © Pedro Peláez
 

library laravel-snappy

Laravel snappy package

image

haska/laravel-snappy

Laravel snappy package

  • Sunday, May 25, 2014
  • by haska
  • Repository
  • 1 Watchers
  • 1 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel snappy package

Informations

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

Usage

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)

The Versions

25/05 2014

dev-master

9999999-dev

Laravel snappy package

  Sources   Download

The Requires

 

by David Haska

laravel image pdf wkhtmltopdf snappy wkhtmltoimage