Using Common Scripts
Large organizations with advanced print scripting requirements may need to share common scripts between different printer queues. Writing a common script allows reuse of JavaScript code and functions without needing to copy script code to all printers, and also makes it much easier for administrators to change and edit the scripts being used on multiple queues.
Writing a common script for multiple queues is quite a simple process. It will involve creating a single JavaScript file on your PaperCut Application Server with as many functions within that file as you would like to create. These functions are created much like as they would in the Scripting window for a single printer.
Creating your common print script
To create your common script file, you will need to create a new file in Notepad++ or something similar, and save it with the name of print-script-common.js
to the [app-path]\server\custom
directory on your PaperCut Application Server.
Each script you will be creating is going to be added to the print-script-common.js
file. When creating your common scripts, it is always best to first create the script on a physical printer queue, testing all variables of the script and ensuring it is working as intended. Once your script is working and you are happy with how it’s running, you can edit the print-script-common.js
file in Notepad++ and add the function to the end of the file.
There is one change that will need to be made for each function you are creating. When adding it to your common print script file, you will need to change the function name to something unique and memorable. Below is a function created for duplex and grayscale to be set for a certain group, you can see I’ve named this function something easy to remember.
To call this function in the printer script, you can see in the below picture that I added a line below my function, which will check the print-script-common.js
script for any functions named this. Please note that any functions in your print script can not be named the same as a function you’ve already named in the print-script-common.js
file.
It is best to test your common print script is working before deploying out to a live printer queue.
Please note that if there is a functionality error in your print-script-common.js
, a warning will be shown on all print script windows, including scripts not calling the common script file. This is to ensure you see any errors for these common print scripts and can remedy the warning.
Categories: How-to Articles , Scripting and APIs
Keywords: master include , global include , global script
Last updated June 13, 2024
Comments