Choose your language

Choose your login

Support

Blog

NEW IN 19.1: Fantastic scripting powers and ways to use them

With Device Scripting joining print scripting in release 19.1, today’s PaperCut admin has unprecedented control over user printing behavior.

From conditional copier access to on-the-fly pricing, it’s about creating advanced scripting rules to improve how people go about printing – whether they’re at the MFD or roaming about the office.

But with so many options, where do you even begin? Join me in exploring three scripts bound to be an excellent starting point for any workplace.

1. Limit color pages per day for print and copy

This usable beauty often tops common request lists from PaperCut customers.

It’s not something we offer in the Admin interface, as the majority of use cases simply call for different pricing for color, greyscale, and varying page sizes – otherwise known as differential charging .

However, a high price tag sometimes isn’t enough to discourage users from printing in color, which is where this script truly comes in handy.

Better yet, we can now bring copying into the mix with 19.1 and Device Scripting.

Getting it done

There are two recipes to easily apply a fixed color limit.

1. Apply a fixed limit on the number of color pages a user can print per day (handled by Print Scripting):

actions.user.onCompletionSaveProperty("color-per-day", currentColorCount);

2. Apply a fixed limit on the number of color pages a user can copy per day (handled by Device Scripting):

actions.user.onCompletionSaveProperty("color-copy-per-day", currentColorCount);

If a user hits either limit, they’ll be forced to print/copy in black and white. Pretty straightforward stuff.

But the magic happens when we make a super quick edit in recipe #2 by swapping out “color-copy-per-day” with “color-per-day”

Now both scripts reference one unified color page limit variable per user, i.e. color copying and color printing contribute toward a single color limit.


2. Apply complex discounts for print and copy

PaperCut MF and NG can allow different printing costs for different conditions via multipliers – and they’re pretty dang handy. Let’s start with some terminology.

Standard discount multipliers

Standard discount multipliers can be applied with the “Multiply print costs by” variable. It basically throws a blanket discount or markup on print, copy, and fax jobs.

Let’s say we have a history lecturer named Vance Skriptin who has a slew of assignments to print and charge back to a shared account.

Vance’s go-to is the history department’s shared account. It has a “multiply print costs by 40%” variable, which equates to a 60% discount on everything that comes through. Simple enough.

Going deeper still, IT can instead opt to apply a discount based on who prints, not where the job’s charged to. Equally useful.

Multi-variable multiplier

“DEEPER!” IT howls, manic and script-drunk.

Vance cowers in his suddenly-sweltering tweed jacket, frightened by their insatiable lust for responsible printing.

“GO DEEPER!”

Were user-based multipliers not enough? Has Vance found himself drowning in the Mariana Trench of scripting cravings? One almost dares not find out.

Anyway, let’s say IT now wants to apply something a bit more involved: a 50% discount on color printing and copying for staff only. Jeepers.

We actually have a recipe for this in our rather comprehensive script template database , so let’s get it done.

Getting it done

Okay, let’s start on the printer side of things. The below script applies a 50% discount on color printing for staff only:

  if (inputs.user.isInGroup("Staff")) {

    // Give the allocated discount
    var newCost = inputs.job.cost - (inputs.job.cost *    (DISCOUNT_AMOUNT/100));
    actions.job.setCost(newCost);

Beautiful. When a print job stops at a PaperCut server to be analyzed, the script runs and charges the discount accordingly.

But being a print script alone, we’ll need to harness our fancy new Device Scripting to get it done for the copy side of things:

/*
* Give staff a 50% discount for copying and scanning.
*/
function deviceJobLogHook(inputs, actions) {

  var DISCOUNT_GROUP   = "Staff";
  var DISCOUNT_AMOUNT  = 50; // 50% off

  // Check if user is a staff member and that this was a copy job
  if (inputs.user.isInGroup(DISCOUNT_GROUP) && (inputs.job.isCopy || inputs.job.isScan)) {

    var discountedCost = inputs.job.cost - (inputs.job.cost * (DISCOUNT_AMOUNT / 100));

    actions.job.setCost(discountedCost);
  }
}

Hooray! Vance doesn’t get sucked into a void of unhealthy script obsession that slowly destroys his life.

Keen to go even deeper on the above script? Get an in-depth walkthrough of an extended version .


3. Block printing/device use after hours

Government departments deal with a lot of sensitive information, so they naturally go to some lengthy lengths to prevent any leaks or mishandling.

In fact, one of our government clients used scripting to limit their staff’s access to devices outside standard business hours (8am-6pm weekdays).

Here’s something similar to what they ran with:

var DAY_START = 8;
var DAY_END = 18;
var hour = inputs.job.date.getHours();
if (hour < DAY_START || hour > DAY_END) {
actions.job.cancelAndLog("Print job was cancelled as it was not printed during business hours");
}

Boom. Any printing before or after hours gets cancelled, and the user receives a friendly notification via the User Client.

You can also do the same for off-the-glass copier use with – you guessed it – Device Scripting (is there anything it can’t do?):

function deviceLoginHook(inputs, actions) {
  var DAY_START = 8;
  var DAY_END = 18;
  var hour = inputs.job.date.getHours();
  if (hour < DAY_START || hour > DAY_END) {
    	//deny login access
    	actions.login.denyLoginAccess()
      }
}

A couple of API actions to note:

  • “actions.login.denyLoginAccess()” blocks the user from logging in to the device; and
  • actions.login.denyColorCopyAccess()” blocks color copying on login.

Keen to go even deeper on the above script? Get an in-depth walkthrough of an extended version .


Thanks for the read!

Here’s hoping I’ve led you to some new ideas in my rambling, or even inspired you to make your foray into scripting.

Some housekeeping to finish:

  1. Visit our Help Center page for all the whiz-bang API actions you’ll need to build a powerful device script.
  2. Let us know your suggestions for handy recipes we can built.
  3. Watch this space for some excellent new updates to our print scripting API coming soon.

Newsletter

Subscribe for the latest in print management and product updates!

By filling out and submitting this form, you agree that you have read our Privacy Policy, and agree to PaperCut handling your data in accordance with its terms.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.