Jump to content

Recommended Posts

Posted

Could someone cleverer than me point me in the right direction for this script?

 

I want a pop-up to appear when users print in colour, giving them two options - "Convert to Greyscale" and "Continue to print in Colour". There are pre-made recipies which cancel the print if Convert to greyscale isn't selected. but none that allow colour printing if necessary.

Posted

Thank you - the pre-defined 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;
 }
 
 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;
   }
 }
}

Posted

You should be able to change it by changing 1 function call:

 

instead of it calling: "actions.job.cancel();" make it call: "actions.job.convertToGrayscale();"

 

try this:

 


/*
* Request user for grayscale/color printing
*
*/
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.
 */

 var CONVERT_MESSAGE = 'Your job contains color pages. Would you like to convert your job to grayscale? Selecting "No" will print the job in color, Selecting "YES" will change the job to greyscale.';
 

 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. 
   */
     if (inputs.client.isRunning) {
     // User is running the client software. Ask if they want to convert to grayscale or cancel.
     var response = actions.client.promptYesNo(CONVERT_MESSAGE);
     
     if (response == 'NO') {
       actions.log.debug('User chose to keep on printing in color');
     } else if (response == 'TIMEOUT') {
       actions.log.debug('Dialog timed out, canceling job.');
       actions.job.cancel();
     } else {
       actions.log.debug('User chose to convert their job to grayscale.');
       actions.job.convertToGrayscale();
     }
   } else {
     actions.log.debug('Canceling job due to high number of color pages and user not running client software.');
     actions.job.cancel();
   }
 }
}

 

Because it´s vacation time now here, i was not able to test it, but it should work. I use something similar but for Duplex printing instead.

  • Thanks 1
  • 5 months later...
Posted

Hi, I have tried this script (after our own failed to convert the document to grayscale) and the document is still coming out in colour. I have tried various things but it's not changing. If I change the individual setting to B&W in the document it does print out B&W. If anyone has any ideas they would be much appreciated.

Thanks

Karen

We are running PapercutMF 12.1 if that helps :)

Posted

give this a go, however it will only convert compatible print drivers- what driver are you using?

 

function printJobHook(inputs, actions) {

 

var CONVERT_MESSAGE = 'Your job contains color pages. Would you like to convert your job to grayscale? Selecting "No" will print the job in color, Selecting "YES" will change the job to greyscale.';

 

 

if (!inputs.job.isAnalysisComplete) {

 

return;

}

 

if (inputs.job.isColor) {

 

if (inputs.client.isRunning) {

var response = actions.client.promptYesNo(CONVERT_MESSAGE);

 

if (response == 'NO') {

actions.log.debug('User chose to keep on printing in color');

} else if (response == 'TIMEOUT') {

actions.log.debug('Dialog timed out, canceling job.');

actions.job.cancel();

} else {

actions.log.debug('User chose to convert their job to grayscale.');

actions.job.convertToGrayscale();

}

} else {

actions.log.debug('Canceling job due to high number of color pages and user not running client software.');

actions.job.cancel();

}

}

}

Posted

Isnt that the exact same script I posted 4 posts up?

 

But as Min has said, you do require a driver which supports this functionality!

Posted
good spot Wiebbe! apologies didn't look properly. i found that script works perfectly with a Ricoh PCl5 driver.
Posted

If you're having any issues with grayscale conversions (or anything else related to page analysis and modifying jobs), please drop us a line at [email protected] detailing the issue, including brand/model of device, driver version (PCL5/6, PS), etc.

 

There are literally thousands of different combinations of PDL flags that can be used by a driver to set things like duplex, so we're always improving our support in those areas. Check out the Printer Compatibility Improvements section in our release notes (Release History - PaperCut) to see the number of changes we make per release.

 

We may ask you to generate some spool files for us for analysis, but we can usually turn around a patch in a week for you to test out and then it's bundled into the core software for future releases.

Posted

Many thanks for this. I'm not very technical but the drivers we are using are PCL6. This script didn't work either. We are trying to come up with a work around and have been in touch with Papercut in the UK, still to no avail.

Thanks again - it was appreciated.

We will keep trying.

Karen

Posted
Many thanks for this. I'm not very technical but the drivers we are using are PCL6. This script didn't work either. We are trying to come up with a work around and have been in touch with Papercut in the UK, still to no avail.

Thanks again - it was appreciated.

We will keep trying.

Karen

 

If you have a support ticket ID (something like #BMN-123-456-789) and you'd like me to take a look, please let me know here. Without knowing specifics, I'd recommend upgrading to the latest version (v13.0), as continual improvements are made to the code that handles grayscale conversions as I noted in a previous post.

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