Package
Barryvdh Laravel Snappy
Snappy PDF/Image for Laravel
Overview
What Barryvdh Laravel Snappy does
Barryvdh's Laravel Snappy integrates Snappy PDF and Image generation into Laravel, providing a seamless way to convert HTML content into PDFs or images directly within applications.
The package acts as a bridge to the KnpLabs Snappy library, which itself is a wrapper around the wkhtmltopdf and wkhtmltoimage tools. This allows Laravel developers to easily generate PDFs and images from HTML content without having to deal with the intricacies of these command-line tools directly.
Using Laravel Snappy involves installing the wkhtmltopdf binaries, either directly from their website or as a composer dependency, and configuring the paths to these binaries. Once setup is complete, developers utilize the service provider and optional facades to generate the necessary files. HTML strings, files, or views can be converted to PDFs, which can be saved, displayed inline, or downloaded.
The integration shines in applications that require regular PDF generation from dynamic content, such as invoices or reports. Developers can leverage methods like loadHTML and loadView to process content and customize output preferences, such as paper size and orientation. For testing, the package offers a PDF fake method that assists in validating PDF generation logic without creating actual files, making it ideal for test-driven development.
This overview was generated by AI from the package README and may not reflect the latest release.
Read the full README →