Choose your language

Choose your login

Contact us

Print scripting / advanced scripting overview

This page applies to:

Print scripts are segments of code that PaperCut NG/MF runs whenever a new print job arrives in the queue.

PaperCut NG/MF’s advanced scripting interface is a powerful and flexible feature that you can use to define and fine-tune your printing policy. While there are many features that you can enable by selecting checkboxes and changing options in the Admin web interface, scripting your own behavior introduces a whole new level of customization.

Common uses for print scripting

The functionality made possible by scripting is varied and is constantly being extended based on customer demand. Some common uses include the following:

  • Displaying a popup message if a user forgets to select duplex on large jobs.
  • Showing a dialog that displays environmental impact statistics about a user’s print job, such as the amount of carbon dioxide equivalent greenhouse gases produced.
  • Prompting the user to confirm large jobs before printing.
  • Automatically routing large jobs to more efficient, high-volume printers.
  • Requesting job data/security classification.
  • Giving discounts during off-peak times.
  • Charging printing to departments during class time.
  • Displaying warning messages under selected conditions.
  • and many, many more.

All of the above uses are possible by writing a small JavaScript directly into a code editor in the Admin web interface. In fact, the above functionality is provided as pre-built recipes ready to use, just like you can with Device scripting . Alternatively, you can build your own scripts to suit your organization’s needs.

At a high level, advanced print scripting provides the ability to:

  • adapt logic based on print job attributes such as cost, pages, document name, time, etc.
  • modify job attributes and behavior such as routing the job to another printer, influencing job cost and account charged, and appending metadata such as comments
  • interact with end users via client messages and popups/dialog boxes.
Screenshot of a Printing Policy Alert message advising users to please use double-sided printing.

Example of a message displayed by a print script.

All of PaperCut NG/MF’s print scripts are written using JavaScript (also known as ECMA-262 ECMAScript.) For more information about JavaScript, see:

The script is defined using the concept of a “hook”. A hook is a JavaScript function (for example, function printJobHook(inputs, actions) { }) that is called for each new job. Your print script defines this method, its behavior, and its actions.

All scripts are defined on a per-printer basis allowing each printer to have its own logic. You can also share/copy a common script between printers by either Copying printer settings or using a common script.

Previous experience with scripting or programming is strongly recommended. However, PaperCut NG/MF does provide a number of tools to assist with script development, including:

  • a mini JavaScript editor with basic error checking and syntax highlighting
  • quick access to a code cookbook containing dozens of best-practice recipes
  • pre-canned “code snippets” demonstrating the use of key functions
  • simple debugging tools such as logging and runtime error reporting.

Configuration topics

For more information about creating print scripts, see:

Comments