Snappy is a PHP library allowing thumbnails, snapshots, and PDF generation from a URL or HTML page. Barry vd. Heuvel is the author of a Laravel Snappy (which has been around since Laravel 5), making it even easier to integrate with Laravel:
1// Generate a PDF From a view2$pdf = PDF::loadView('pdf.invoice', $data);3$pdf->download('invoice.pdf');45// Generate a PDF from a URL6PDF::loadFile('https://www.github.com')7 ->inline('github.pdf');89// Change the orientation and paper size10PDF::loadHtml($html)11 ->setPaper('a4')12 ->setOrientation('landscape')13 ->setOption('margin-bottom', 0)14 ->save('myfile.pdf');
Along with some nifty convenience methods, Snappy for Laravel has testing features to help you assert things that Snappy generates:
1PDF::fake();23// Perform order shipping...45PDF::assertViewIs('view-pdf-order-shipping');6PDF::assertSee('Name');
Snappy requires the wkhtmltopdf (available on Windows, Mac, and Linux), which is a command-line tool to render HTML into PDF and various image formats. Installation instructions are available in the readme so you can ensure wkhtmltopdf is installed and the path configured properly.
The code examples are directly from the project’s readme; be sure to check it out for more examples of available methods and test assertions.