My System Admin wants to script this Javascript for our papercut system and this is what I have so far.
When I try to print no pop ups come up I need help if possible. I need one pop to come up one after another.
/*
-
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.
” - “Do you want to print this job?”,
{“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();
return;
}
}
}
function printJobHook1(inputs, actions) {
var LIMIT = 20; // Show message for jobs over 20 pages.
/*
- 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.totalPages > LIMIT) {
/*
* Job is larger than our page limit, so ask the user to confirm via
* red warning message so we grab their attention.
*/
var message = “”
+ “This print job is over " + LIMIT + " pages. Please confirm the job.”
+ “”;
var response = actions.client.promptPrintCancel(message);
if (response == “CANCEL” || response == “TIMEOUT”) {
// Cancel the job and exit the script.
actions.job.cancel();
return;
}
// User pressed OK, so allow it to print - simply return taking no action.
}
}
function printJobHook(inputs, actions) {
printJobHook2(inputs, actions);
printJobHook1(inputs, actions);
}