skennedy Posted December 5, 2016 Posted December 5, 2016 I am currently using a script to offer for jobs to be printed in black and white. It displays the cost if printed in colour. My issue is papercut then displays a 2nd pop up if you say "No" (convert to grayscale) but still displays original cost of colour. The print does charge correctly and prints in black and white but the 2nd pop up displays the incorrect cost. /* * 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 grayscale. " + "Are you sure you would like this print job in colour?", {"dialogTitle" : "Colour print job", "dialogDesc" : "Consider printing in grayscale to reduce costs"}); if (response == 'NO') { actions.job.convertToGrayscale(); } else if (response == 'TIMEOUT') { actions.job.cancel(); } else { return; } } } 1st pop up: 2nd pop up:
mikkydoos Posted December 5, 2016 Posted December 5, 2016 (edited) Heres mine... try comparing. /* * 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; } if (inputs.job.isColor) { /* Color job, ask the use if they want to print. The job cost is displayed * prominently to encourage users to consider black and white printing instead. */ var response = actions.client.promptPrintCancel( "This print job is color" + " and costs " + inputs.utils.formatCost(inputs.job.cost) + ". You can save money by printing the job in grayscale. " + "Press Print to Print in Colour. Press Cancel to convert to Greyscale", {"dialogTitle" : "Color print job", "dialogDesc" : "Consider printing in grayscale to reduce costs"}); if (response == "CANCEL" || response == "TIMEOUT") { // User did not respond, cancel the job and exit script. //actions.job.cancel(); actions.job.convertToGrayscale(); return; } } } ------------------------------------------------- Is that screen shot from a Mac ? How did u get Yes/No buttons instead of Yes/Cancel ? Edited December 5, 2016 by mikkydoos
skennedy Posted December 5, 2016 Author Posted December 5, 2016 var response = actions.client.promptPrintCancel change this to var response = actions.client.promptYesNo Yes we are working on Mac, This unfortunately still brought up a 2nd pop up for me with incorrect pricing again. 1
mikkydoos Posted December 5, 2016 Posted December 5, 2016 // 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 grayscale. " + "Are you sure you would like this print job in colour?", {"dialogTitle" : "Colour print job", "dialogDesc" : "Consider printing in grayscale to reduce costs"}); } I think you've got a missing closing curly bracket here on that If clause
skennedy Posted December 5, 2016 Author Posted December 5, 2016 Unfortunately no luck there either. It then comes up with an error when adding the }
mikkydoos Posted December 5, 2016 Posted December 5, 2016 (edited) Try this.... function printJobHook(inputs, actions) { if (!inputs.job.isAnalysisComplete) { return; } if (inputs.job.isColor) { 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 grayscale. " + "Are you sure you would like this print job in colour?", {"dialogTitle" : "Colour print job", "dialogDesc" : "Consider printing in grayscale to reduce costs"}); if (response == 'NO') { actions.job.convertToGrayscale(); } else if (response == 'TIMEOUT') { actions.job.cancel(); } else { return; } } } Are you sure the script isn't running twice. I.e. you're only running it on the virtual print queue not the printer aswell? The script looks fine to me. Have you tried it on another machine - not a Mac ? Or is it a Mac PPC server? Also if my script does the same (I think your have to restart the Papercut Print Processor service when you amend a script (I might be wrong!!)) then you've got something wrong other than your script I'd say. Mine definitely works. 100%. Edited December 5, 2016 by mikkydoos
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