PHP code example of jjclane / laravel-print-node

1. Go to this page and download the library: Download jjclane/laravel-print-node 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/ */

    

jjclane / laravel-print-node example snippets


'providers' => [
    ...
    Infernobass7\PrintNode\PrintNodeServiceProvider::class,
    ...
]

return [
    'auth' => [
        /*
         * Use this to set either API Key or email
         */
        'username' => '',
        
        /*
         * Do not set this if you are using API Key
         */
        'password' => ''
    ],
    
    'options' => [
        /*
         *  * = Options only available when installed client is running on a OSX Machine
         */
//      'bin' => , // String
//      'collate' => , // Boolean
//      'copies' => , // Integer
//      'dpi' => , // String
//      'duplex' => , // String - "long-edge" or "short-edge"
//      'fit_to_page' => , // * Boolean
//      'media' => , //String
//      'nup' => , // * String - Print Multiple Pages on One Sheet
//      'pages' => , // String - Specific Set of pages from the PDF. Format explained here https://printnode.com/docs/api/curl/#parameters
//      'paper' => , // String - Named paper size
//      'rotate' => // Integer - Rotate Page specified degrees ( accepted values: 90, 180, or 270 )
    ]
];

/*
 * Will return a collection of Printer Objects 
 */
Printer::all();
 
/*
 * Will return the specific printer Object based on the ID.
 * The ID can retrieved from PrintNode's service.
 */
$printer = Printer::get($printer_id);

/*
 * Retrieve a list of all PrintJobs previously printed on the Printer
 */
$previousJobs = $printer->getPrintJobs(); 
 
/*
 * Retrieve a specific print job previousl printed on the Printer
 */
$previousJob = $printer->getPrintJob($id);

/*
 * Create a new PrintJob
 */
$job = new PrintJob($attributes = []);
 
/*
 * Sends the print job to the specified Printer
 */
$job->print(Printer $printer);
// Alternatively
$printer->print(PrintJob $job);

/*
 * Fluent Setters to create PrintJob
 */
 
/*
 * Grabs file based on the path of the storage disk defined in Storage Configuration 
 * Set contentType to either 'raw_base64' or 'pdf_base64'
 */
$job->setFile($path, $disk = 'local', $raw = false);

/*
 * Sets the content to the URI provided
 * Sets Credentials for basic Authentication type
 */
$job->setUri($uri, $credentials = null, $raw = false);
// Alternatively 
$job->setUri($uri)->setAuthentication($credentials, $basic = true);

/*
 * 
 */
$job->setOptions($options = []);

/*
 * Please note the next two methods are not the same.
 */

/*
 * Sets the number of times that the PrintJob is going to be sent to the Printer
 */
$job->setQuantity(int $qauntity);

/*
 * Sets the number of copies that are printed per PrintJob
 */
$job->setCopies(int $quantity);

/*
 * Sets the source name to display on PrintNode
 */
$job->setSource($name);

/*
 * Sets how long in seconds the PrintJob will sit in the queue waiting to be printed
 * Afterwards it will be deleted
 */
$job->setExpireAfter(int $seconds);

php artisan vendor:publish --provider="Infernobass7\PrintNode\PrintNodeServiceProvider"