PHP Direct Print
This library allows printing files directly from PHP.
Avoid print dialog preview in the web browser. Linux and MacOS Compatible. CUPS Required., (*1)
Installation
Include the library
Composer
If you are using composer, then add neysi/directprint as a dependency:, (*2)
composer require neysi/directprint
Manual
If you have no composer, download the code and include autoload.php, (*3)
git clone https://github.com/neysi/directprint.git
<?php
require __DIR__ . '/vendor/neysi/directprint/autoload.php');
Methods
printFile($fileName,$printerName)
Print on the default printer:, (*4)
$id = DirectPrint::printFile('invoice.pdf') ;
Print on the Canon iP2800 Printer:, (*5)
$id = DirectPrint::printFile('invoice.pdf','Canon_iP2800_series') ;
getDefaultPrinter()
$printerName = DirectPrint::getDefaultPrinter() ;
getPrinters()
$printers = DirectPrint::getPrinters() ;
activeJobs()
Displays print queue, (*6)
cancelAllJobs()
Cancel all of the print queue, (*7)
cancelJob($jobID)
Cancel a specific print job, (*8)