PHP code example of thenodi / printer-wrapper

1. Go to this page and download the library: Download thenodi/printer-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thenodi / printer-wrapper example snippets



(new \TheNodi\PrinterWrapper\PrinterManager())->printFile('/path/to/file.txt');


(new \TheNodi\PrinterWrapper\PrinterManager())->printers();
// => Printer[]


(new \TheNodi\PrinterWrapper\PrinterManager())
    ->landscape()
    ->printFile('/path/to/file.txt');


(new \TheNodi\PrinterWrapper\PrinterManager())
    ->media(\TheNodi\PrinterWrapper\Printer::MEDIA_LETTER)
    ->printFile('/path/to/file.txt');


(new \TheNodi\PrinterWrapper\PrinterManager())
    ->twoSided()
    ->printFile('/path/to/file.txt');


(new \TheNodi\PrinterWrapper\PrinterManager())
    ->setOption('only-name')
    ->setOption('name', 'value')
    ->printFile('/path/to/file.txt');
// => lp -o only-name -o name=value ...