stan780953 Posted February 2, 2015 Posted February 2, 2015 Hi, Not sure if this is the best place to post the following but her goes. I would like to create a script in Papercut which will test a print job and if the size is anything other than A4 or A3 the user will get a message saying their print job has been canceled and to send the job as the correct size. This can be done with the filter/Restriction but the message is basic. Any help would be very much appreciated as my scripting knowledge is not that great. Thank you
forkies Posted February 3, 2015 Posted February 3, 2015 Try this: /* * * Warn and deny users when printing other than A4 or A3 * */ function printJobHook(inputs, actions) { /* * Edit the settings below according to your policy and environment. */ // Paper size that is allowed var ALLOWED_PAPER_SIZE = [ 'A4', 'A3', 'outbind://' ]; if (!inputs.job.isAnalysisComplete) { // No job details yet so return. return; } var message; var response; if (inputs.job.paperSizeName(ALLOWED_PAPER_SIZE)) { var response = actions.client.promptPrintCancel( "This print job is not A4 or A3" + ". You must resend this in A4 or A3 page size.", {"dialogTitle" : "Wrong paper size", "dialogDesc" : "Check your paper size"}); if (response == "CANCEL" || response == "TIMEOUT") { // User did not respond, cancel the job and exit script. actions.job.cancel(); return; } } }
stan780953 Posted February 3, 2015 Author Posted February 3, 2015 Hi, Thank you for your prompt reply. I've tried the script but get the following error, any ideas? Error in "printJobHook" - TypeError: Cannot call property paperSizeName in object PrintJob[date=Tue Feb 03 09:29:34 GMT Document1,totalPages=1,paperSizeName=A6,grayscale=true,duplex=true]. It is not a function, it is "string". (printer-script#25) Thank you
spadam Posted February 3, 2015 Posted February 3, 2015 Try changing the second if condition for this: if (ALLOWED_PAPER_SIZE.indexOf(inputs.job.paperSizeName) == -1) {
forkies Posted February 3, 2015 Posted February 3, 2015 Try changing the second if condition for this: if (ALLOWED_PAPER_SIZE.indexOf(inputs.job.paperSizeName) == -1) { Thats the one, sorry didn't check before I submitted.
forkies Posted February 3, 2015 Posted February 3, 2015 Here is the updated one, I have checked. The first one still allowed them to print were as this one just gives them a message and stops the print job. /* * * Warn and deny users when printing other than A4 or A3 * */ function printJobHook(inputs, actions) { /* * Edit the settings below according to your policy and environment. */ // Paper size that is allowed var ALLOWED_PAPER_SIZE = [ 'A4', 'A3', 'outbind://' ]; if (!inputs.job.isAnalysisComplete) { // No job details yet so return. return; } var message; var response; if (ALLOWED_PAPER_SIZE.indexOf(inputs.job.paperSizeName) == -1) { var response = actions.client.promptOK( "This print job is not A4 or A3" + ". You must resend this in A4 or A3 page size.", {"dialogTitle" : "Wrong paper size", "dialogDesc" : "Check your paper size"}); if (response == "OK" || response == "TIMEOUT") { // User did not respond, cancel the job and exit script. actions.job.cancel(); return; } } } 1
stan780953 Posted February 3, 2015 Author Posted February 3, 2015 Brilliant, Works a treat!!! Thank you for all your help.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now