Choose your language

Choose your login

Contact us

Printer Failover with Print Scripting

THE PAGE APPLIES TO:

In some situations, you might want high availability failover for your printing. That is, have all printing to go to 1 specific printer, but redirect to another, secondary printer if that primary one is offline or in error.

Printers in PaperCut do have load balancing functionality, but that’s not quite what we’re after here.

The way to get this to work is actually through the use of a Print Script.

The setup is fairly simple.

  • Have two physical printers in PaperCut. One as the primary printer, the other is the secondary/failover printer.
  • Attach the below print script to the primary printer

Note: This script is designed to be used in setups where hold/release is not being used. So when the print job will automatically print out after being submitted by the user.

function printJobHook(inputs, actions) {

if (!inputs.job.isAnalysisComplete) { return; }

//Change this to be the name of the secondary/failover printer var SecondaryPrinter = “Secondary Printer Name”;

//Check if this printer (primary) is in error, if it is, redirect to the secondary printer and add a comment if(inputs.printer.isStatusError){ actions.job.addComment(“Redirected”); actions.job.redirect(SecondaryPrinter);

} else { //if it’s not in error, add a comment saying it wasn’t redirected actions.job.addComment(“Not redirected”); } }

On line 8 you will find the variable SecondaryPrinter. You will want to change the value of this to be the name of your failover printer.

Once you’ve made that change and saved this script to the printer you will want to run some tests to make sure it’s working

Test

  1. Have both printers working and send some jobs, make sure they come out of the primary printer

  2. Make the primary printer fail (eg remove all the paper), and send some jobs.

    • The first might not redirect, due to PaperCut not knowing the printer is in error yet, once PaperCut knows it’s in error the redirections should start.
  3. “fix” the primary printer and print some jobs, we want to make sure it fails back over to the primary.


Categories: How-to Articles , Print Queues


Keywords: printer script , failover , high availability , load balance , priority

Comments

Last updated February 19, 2024