dobsonl Posted June 3, 2015 Posted June 3, 2015 Hi Guys, I am trying to write a script (my first one!) for papercut to prompt our users if the print job is colour to confirm they would like to print the document or convert it to greyscale. I have this script but I don't know why it keeps on printing in colour no matter if you click yes or no... is anybody able to look at what I have done wrong please? /* * Color print jobs require user confirmation * * Color printing is expensive so users should be encouraged to print * in grayscale whenever they print in color. No confirmation is required * for grayscale jobs. */ function printJobHook(inputs, actions) { /* * This print hook will need access to all job details * so return if full job analysis is not yet complete. * The only job details that are available before analysis * are metadata such as username, printer name, and date. * * See reference documentation for full explanation. */ if (!inputs.job.isAnalysisComplete) { // No job details yet so return. return; } // Test if the job is color (contains at least 1 color page) if (inputs.job.isColor) { // Add your action code here var response = actions.client.promptYesNo("This print job is color" + " and costs " + inputs.utils.formatCost(inputs.job.cost) + ". You can save money by printing the job in grayscale. " + "Are you sure you would like this print job in colour?", {"dialogTitle" : "Colour print job", "dialogDesc" : "Consider printing in colour to reduce costs"}); if (response == 'No') { actions.job.convertToGrayscale(); } else if (response == 'TIMEOUT') { actions.job.cancel(); } else { return; } } }
Steve21 Posted June 3, 2015 Posted June 3, 2015 Not sure how fussy it is but aren't the responses always in caps? so No should be NO? Steve 1
dobsonl Posted June 3, 2015 Author Posted June 3, 2015 That is perfect spot thank you, have just tested and it now works correctly
clareq Posted June 3, 2015 Posted June 3, 2015 Shouldn't "dialogDesc" : "Consider printing in colour to reduce costs"}); be "dialogDesc" : "Consider printing in monochrome to reduce costs"});?
robslack Posted January 31, 2019 Posted January 31, 2019 This was really useful, should be a default in papercut. I modified the Script to say Black & White as people understand better than grayscale or monochrome. The Script is /* * Color print jobs require user confirmation * * Color printing is expensive so users should be encouraged to print * in grayscale whenever they print in color. No confirmation is required * for grayscale jobs. */ function printJobHook(inputs, actions) { /* * This print hook will need access to all job details * so return if full job analysis is not yet complete. * The only job details that are available before analysis * are metadata such as username, printer name, and date. * * See reference documentation for full explanation. */ if (!inputs.job.isAnalysisComplete) { // No job details yet so return. return; } // Test if the job is color (contains at least 1 color page) if (inputs.job.isColor) { // Add your action code here var response = actions.client.promptYesNo("This print job is Colour" + " and costs " + inputs.utils.formatCost(inputs.job.cost) + ". You can save money by printing the job in Black & White. " + "Press Yes to continue this print job in Colour.Press No to Print in Black & White", {"dialogTitle" : "Colour Print Job Detected", "dialogDesc" : "Consider printing in Black & White to reduce costs"}); if (response == 'NO') { actions.job.convertToGrayscale(); } else if (response == 'TIMEOUT') { actions.job.cancel(); } else { return; } } }
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