laravel-printing
Advanced Usage
Multiple Drivers
On this page
{note} You're browsing the documentation for an old version of laravel-printing. Consider upgrading your project to v3. Check your version with the following command:
`composer show rawilk/laravel-printing`
Introduction
If you have multiple print drivers you need to print with, you can easily do so by calling
driver('driver_name')
on the Printing
facade. This could be useful if you print receipts
through PrintNode and then regular documents through CUPS or some other custom driver you have
installed.
Switching on the fly
By default, the package only supports using one driver at a time, but you can switch to using a different driver at runtime if you need to. Let's say you need to print most documents using PrintNode, but for one specific document, you need to use CUPS. You can do so like this:
// Send a job to printnode
Printing::newPrintTask()
->printer($printerId)
->file('file_path.pdf')
->send();
// Send a job to the cups server
Printing::driver('cups')
->newPrintTask()
->printer($cupsPrinterId)
->file('file_path.pdf')
->send();