img

PaperCut Print Script of the Month #6 – April Fools


PaperCut Print Script of the Month

We like to think we have a sense of humour around here and what better way to keep ourselves entertained than by sending print jobs to the wrong printer for the day, Grab a cup of tea (only joking coffee is the only choice…) and we-can start with the PaperCut scripting fun.

This months script is going to make use of an array to hold the printer names you want to include. If you want to read more about arrays you can check Script of the Month #3.

var printers = ['science_room','maths_room','english_room'];

 

Now the PaperCut method we are going to use will allow us to redirect the job to a printer and also recalculate the cost, of course, you will want to make sure you are using the PaperCut Global Print Driver or that you are using the universal driver for your printers.

The method is below and you can see it requires one parameter which is the printer name, there are also some options we can set for this one to set if the job should be held or if we should recalculate the cost.

actions.job.redirect(printerName[, options])

 

We are only interested in the recalculate cost option, so this changes the method to be like the example below.

actions.job.redirect(printerName, {recalculateCost: true});

 

Now all we need to do is randomly get a printer from the array just like we did with the random quote script back in December, Now we have our complete line which should look like below and we can get everything put together.

actions.job.redirect(printers[ Math.floor( Math.random() * printers.length ) ], {recalculateCost: true});

As always the complete PaperCut print script is below for you to use. If you have your own requirements for a print script and you don’t have the time or in-house experience to make it you can find out how we can help you by sending an email to our sales team at sales@selectec.com

 

/*
 * Send print jobs to random printer
 *
 * Read more at http://selectec.com/script-of-the-month-6-april-fools-2016/
 */
function printJobHook( inputs, actions ) {
 
 if (!inputs.job.isAnalysisComplete) {
 // No job details yet so return.
 return;
 }
 
 // Array of printers
 var printers = ['science_room','maths_room','english_room'];
 actions.job.redirect(printers[ Math.floor( Math.random() * printers.length ) ], {recalculateCost: true});
}
PaperCut Print Script
Latest News from Jonathan Bennetts
img

PaperCut and Access Management

Access Management and Identity as a Service (IDaaS) solutions for PaperCut...

Written by: Jonathan Bennetts

More
img

PaperCut ends client support for 32-bit operating syst...

A long time ago, in a country far far away... PaperCut announced they were...

Written by: Jonathan Bennetts

More

img

You guys are a pleasure to do business with your support is fantastic I wish all suppliers behaved like you

Duncan Vass Dell Ltd
Back to Top ↑