Advanced Usage

Multiple Drivers

{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

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.

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();
Previous
Custom Drivers
Caught a mistake? Suggest an edit on GitHub