PaperCut Print Script of the Month #4 – Colour Only Extensions

PaperCut Print Script – Colour only extensions


This month’s PaperCut Print Script keeps it simple and highlights how we can only allow colour printing from certain applications (for example, Excel, Powerpoint, etc.) based on the file extension. In this example all mono printing is permitted, colour is cancelled if not from one of pre-defined whitelisted applications

Now, before you get excited, this will not work for all applications. It depends on how the print job from the application arrives in a print queue if there is no extension being send then a bit of research would need to be done to work out what the applications send instead that can be used to identify it in the queue. With that small disclaimer out of the way it is time to grab a cup of coffee and get started.

This month we start out with an array which will contain the list of extensions we want to allow colour printing for if you missed last months PaperCut Print Script where we first introduced arrays you can catch up here.

Next up is to work out if the job was actually sent in colour all of our code will be in this if block to make sure it only attempts to run the rest of the script for colour jobs, Luckily PaperCut has a handy method we can use to do this

Now it is time to work out how we are going to get the information out of the array. Last month we directly specified the index to use using something like fileExtensions[1] (in this example that would return .ppt) but we actually want to work with each value and be able to easily change what extension we are allowing. For this, we are going to a for loop which at first might look complicated but it will all make sense

So what we are doing is starting out by setting the value of i to 0 and checking that the value of i is less than the number of extensions in the array if it is we will add 1 to the value of i on the next run. Remember how we manually set the index last month well this month we are making the computer do the work to check each value. This means that on the first loop the value of fileExtensions[i] will be .xls, on the second loop i will equal 1 so fileExtensions[i] will be .ppt and it will keep going through them until the value of i matches what we have in the array.

Now we have that out of the way… lets look at how to work out if the document name contains the extension we are looking for we can use inputs.job.documentName and the indexOf method that can be used on Strings, indexOf will tell us the position that the search string appears and will return a -1 if it doesn’t appear at all. So for this example, we only want to proceed if the extension is found in the filename but the position could be anywhere so for our check we will just make sure the result is not -1.

Now that is all done outside of the loop we can send a message to the client to tell them the document is not allowed to be printed in colour and cancel the job

As always the complete PaperCut Print Script is below and 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

PaperCut Print Script
Latest News from Jonathan Bennetts

Grant temporary access to printers using PaperCut

How do I grant temporary access to company printers?   One of our rese...

Written by: Jonathan Bennetts


Peppermint Technology PaperCut Integration

Peppermint technology PaperCut integrations Selectec were approached by our ...

Written by: Jonathan Bennetts



We have worked with Selectec for a number of years now and they are the perfect PaperCut partner for us. The support team is fantastic and knowledgeable and the sales staff are superb. With the high level of service we get from Selectec we have no reason to consider using anyone else.

Martin Croft Direct-tec Group Ltd
This website works best using cookies which are currently disabled. We use cookies to help with our site analytics to improve our services.
Back to Top ↑