laravel-printing

Basic Usage

Basic Usage

Most operations through this package can be done with the Printing facade. Everything documented on this page will be the same regardless of the driver you are using.

You can retrieve all available printers on your print server like this:

use Rawilk\Printing\Facades\Printing;

$printers = Printing::printers();

foreach ($printers as $printer) {
    echo $printer->name();
}

No matter which driver you use, each $printer object will be an instance of Rawilk\Printing\Contracts\Printer. More info on the printer object here.

You can find a specific printer if you know the printer's id:

Printing::printer($printerId);

If you have a default printer id set in the config file, you can easily access the printer via the facade:

// returns an instance of Rawilk\Printing\Contracts\Printer if the printer is found
Printing::defaultPrinter();

// or for just the id
Printing::defaultPrinterId();

{note} This will only work for the default driver. Any calls to a different driver at runtime (i.e. Printing::driver(...)->defaultPrinter()) will not work.

You can send jobs to a printer on your print server by creating a new print task:

Printing::newPrintTask()
    ->printer($printerId)
    ->file('path_to_file.pdf')
    ->send();
Previous
Changelog