Download the PHP package pxlrbt/laravel-pdfable without Composer
On this page you can find all versions of the php package pxlrbt/laravel-pdfable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pxlrbt/laravel-pdfable
More information about pxlrbt/laravel-pdfable
Files in pxlrbt/laravel-pdfable
Package laravel-pdfable
Short Description This is my package laravel-pdfable
License MIT
Homepage https://github.com/pxlrbt/laravel-pdfable
Informations about the package laravel-pdfable
Laravel Pdfable
Keep the logic for your PDFs in one place like you do with Laravel's Mailables.
Installation
You can install the package via composer:
You can publish the config file with:
Optionally, you can publish the views using
Configuration
Currently two drivers are supported:
- Browsershot (default)
- Wkhtmltopdf (legacy, wkhtmltopdf is deprecated)
Browsershot Driver
This is the default driver and requires spatie/browsershot. Please follow the installation instructions for that package.
You can configure the Browsershot driver via BrowsershotDriver::configureUsing()
in your AppServiceProvider
:
Wkhtmltopdf Driver
To use the wkhtmlpdf Driver, make sure wkhtmltopdf
is installed on your system and globally available.
Then, set the PDFABLE_DRIVER
option in your .env
file to wkhtmltopdf
.
Generating Pdfables
You can use the make command to generate a Pdfable class and view.
Usage
You can directly use, pass or return Pdfables in many places in your app.
As Files
You can store Pdfables via ->store()
method. This will use outputFile()
method on the class to determine the class name. Optionally, you can pass a custom filename.
As Responses
You can either stream, download or return your Pdfables HTML for debugging.
HTML
To return HTML in a debugging view, just return the Pdfable.
Stream
To stream your Pdfable, add the ->stream()
method.
Download
To download your Pdfable, add the ->download()
method. Optionally, you can also override the filename from here.
As Mailable Attachment
To use a Pdfable as a mail attachment, just pass it via ->attach()
. Make sure your mailables/notifications are queued for faster processing.
As Jobs
Pdfs can take some time to create, so you can queue your Pdfables and create them in the background with the known Laravel methods.
Writing Pdfables
Once you have generated a pdfable class, open it up so we can explore its contents. Pdfable class configuration is done in several methods.
Configuring The View
The view is configured via static $view
property.
Configuring The Page/Layout
You can return a Page
object to configure the PDF page size, orientation and margins.
Passing Additional Data
Pass additional data via the constructor of your Pdfable for later use.
Accessing Data From View
Similar to Laravel's Blade Components you can access properties and public methods directly from your view file.
Configuring The Output File
When saving a Pdfable to the disk, you can provide a default path via filename()
and override the default disk via $disk
property.
Queuing A Pdfable
Pdfables implement ShouldQueue
and therefore can be pushed to a queue via Invoice::dispatch()
. You can also use other queue configuration methods directly on your Pdfable like backoff()
, retryUntil()
, uniqueId()
, ...
Credits
- Dennis Koch
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-pdfable with dependencies
spatie/laravel-package-tools Version ^1.13.0
illuminate/contracts Version ^9.0|^10.0|^11.0