Jump to content

Recommended Posts

Posted

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:

Screen Shot 2016-12-05 at 10.19.41.png

 

2nd pop up:

Screen Shot 2016-12-05 at 10.20.00.png

Posted (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 by mikkydoos
Posted

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.

  • Thanks 1
Posted

// 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

Posted (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 by mikkydoos

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...