Choose your language

Choose your login

Support

How can we help?

PaperCut's AI-generated content is continually improving, but it may still contain errors. Please verify as needed.

Lightbulb icon
Lightbulb icon

Here’s your answer

Sources:

* PaperCut is constantly working to improve the accuracy and quality of our AI-generated content. However, there may still be errors or inaccuracies, we appreciate your understanding and encourage verification when needed.

Lightbulb icon

Oops!

We currently don’t have an answer for this and our teams are working on resolving the issue. If you still need help,
User reading a resource

Popular resources

Conversation bubbles

Contact us

Troubleshooting print scripts

This page applies to:

Last updated October 8, 2025

The Advanced Scripting window has some simple debugging tools such as logging and runtime error reporting.

Where possible the error message indicates the line number on which the error was found and the relevant line is highlighted.

Error messages are classed into two groups:

Scripting syntax errors

These are detected and displayed when you click Apply. The error message indicates the line number on which the error was found and the relevant line is highlighted. The script does not save until all syntax errors are addressed.

Scripting runtime errors

These are errors that occur when a script is executed. To see the errors, refresh the Scripting tab. The error message indicates the line number on which the error was found and the relevant line is highlighted.

Where possible the error message indicates the line number on which the error was found and the relevant line is highlighted:

Runtime errors are also logged and displayed on the App Log tab:

Debugging (troubleshooting) common scripting errors

Hint: Any error should also have a line number indicating where the issue was. e.g. (printer-script#16) indicates line 16 is where the problem is.

Example 1: TypeError: Cannot find function

e.g. Error in "printJobHook" - TypeError: Cannot find function isingroup in object User[username=john.doe,fullName=,restricted=false]. (printer-script#16)

Code:

if (inputs.user.isingroup("Students")) {

Solution:

The above error indicates that the script can not find the function specified. In this specific case, the Letter Case of the function name is incorrect. Instead of inputs.user.isingroup() you will need to use inputs.user.isInGroup

Example 2: The script failed to validate

e.g. The script failed to validate, check the script syntax: invalid return (printer-script#17)

Code:

function printJobHook(inputs, actions) {
    if (!inputs.job.isAnalysisComplete)
    // No job details yet so return.
    return;
}

if (inputs.job.isColor) {
  var response = actions.client.promptPrintCancel(
    "<html>This print job is <span style='color:red'><b>color</b></span>"
    + " and costs <b>" + inputs.utils.formatCost(inputs.job.cost)
    + "</b>.  You can save money by printing the job in grayscale.<br><br>"
    + "Do you want to print this job?</html>",
    {"dialogTitle" : "Color print job",
     "dialogDesc"  : "Consider printing in grayscale to reduce costs"});
  if (response == "CANCEL" || response == "TIMEOUT") {
    actions.job.cancel();
    return;
  }
}
}

Solution:

This one is a bit harder to diagnose. The error indicates that the return; on line 17 is invalid. This is caused by a missing { on line 2. if (!inputs.job.isAnalysisComplete) should be if (!inputs.job.isAnalysisComplete) {

 

Most print scripts will not be impacted by this, you only need to take action if you have you’ve implemented advanced scripting using E4X.

With the release of PaperCut NG/MF version 25, we’ve updated the underlying JavaScript engine to a modern version of Mozilla Rhino to enhance security. As a consequence of this update, support for the ECMAScript for XML (E4X) standard has been deprecated.

Any print scripts that rely on E4X commands, such as new XML to create or handle XML objects, will no longer function after upgrading to v25.

If your print scripts currently use E4X, you must update them to be compatible with version 25.

Option 1: Rewrite the Script Using the DOMParser API

You can continue using XML by rewriting your script to use modern, standard JavaScript APIs. Instead of the old E4X commands, you should use the DOMParser API to parse the XML string into a workable document.

More information about the DOMParser API can be found here: https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

Option 2: Switch from XML to JSON

An alternative is to modify your data source to send a JSON object instead of XML. The new JavaScript engine in v25 has native support for JSON, allowing for straightforward parsing using the standard JSON.parse() command.

 

Comments