2017 © Pedro Peláez
 

library laravel-print-node

Print using PrintNode in Laravel. http://www.printnode.com

image

infernobass7/laravel-print-node

Print using PrintNode in Laravel. http://www.printnode.com

  • Thursday, May 18, 2017
  • by infernobass7
  • Repository
  • 2 Watchers
  • 3 Stars
  • 73 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 6 % Grown

The README.md

Laravel-PrintNode

Laravel Wrapper for PrintNode API. More about PrintNode can be found here: http://www.printnode.com, (*1)

Laravel 5

This package has been written in Laravel 5.4 but should support previous versions of Laravel 5., (*2)

Installation

You can pull this package in through Composer., (*3)

composer require infernobass7/laravel-print-node

You will need to add the following lines to config/app.php, (*4)

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

Next you will want to publish the config file., (*5)

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

Configuration

The config files comes with two sections out of the box. The first is auth, which is required in order for the package to work. The username is either the API Key or the email address. If you use the API Key you should not provide a password. However, if you use an email address, you must provide the password too. The second section is the configuration options for printing. These will be used as a default should you not specify any while creating a PrintJob., (*6)

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 )
    ]
];

Usage

Printer

This class handles retrieving list of Printers from PrintNode., (*7)

/*
 * 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);

This class handles retrieving and creating new PrintJobs., (*8)

/*
 * 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);

The Versions

18/05 2017

dev-master

9999999-dev

Print using PrintNode in Laravel. http://www.printnode.com

  Sources   Download

The Requires

 

by Michael Deck

18/05 2017

dev-analysis-8Q1kbp

dev-analysis-8Q1kbp

Print using PrintNode in Laravel. http://www.printnode.com

  Sources   Download

The Requires

 

by Michael Deck

27/04 2017

v0.1.1

0.1.1.0

Print using PrintNode in Laravel. http://www.printnode.com

  Sources   Download

The Requires

 

by Michael Deck

26/04 2017

v0.1.0

0.1.0.0

Print using PrintNode in Laravel. http://www.printnode.com

  Sources   Download

The Requires

 

by Michael Deck