Combining Script Recipes

KB Home   |   Combining Script Recipes

It is possible to combine Advanced Scripts. Someone with an understanding of JavaScript should be able take parts from two or more existing scripts and combine them.

This article is intended to help people who are not JavaScript programmers combine two recipes so they run one after the other. It is not a replacement for understanding JavaScript.

A typical Advanced Script contains one printJobHook() function

    function printJobHook(inputs, actions) {
       ... some JavaScript code ...
    }

PaperCut calls printJobHook once per print job. If you wish to have two recipes called for a job then you must call them both from one printJobHook() function.

A simple way to do this is

  • Copy the first recipe into your script and rename its printJobHook to printJobHook1.
  • Copy the second recipe into your script and rename its printJobHook to printJobHook2.
  • Below the two renamed recipes (at the very end of the script text) add a printJobHook function that calls printJobHook1 then printJobHook2. It will look like this
        function printJobHook(inputs, actions) {
            printJobHook1(inputs, actions);
            printJobHook2(inputs, actions);
        }

If both recipes work individually on your printer and it makes sense to call recipe 2 after recipe 1 then this combined script should do that for you.

Troubleshooting a Combined Script

If your combined script does not work on your printer then

  • Check that recipe 1 alone works on your printer. You can do this by saving the combined script in a text editor and re-importing recipe 1.
  • Check that recipe 2 alone works on your printer. You can do this by saving the combined script in a text editor and re-importing recipe 2.
  • Confirm that it makes sense to call recipe 2 after recipe 1.

If the combined script still does not work then there may be some JavaScript knowledge required. In this case you should discuss your script with someone who knows JavaScript.


Categories: Scripting


Keywords: combine, combining, script, scripts, scripting

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on July 10, 2014, at 06:51 PM
Printable View   |   Article History   |   Edit Article