+ Post New Thread
Results 1 to 14 of 14
Network and Classroom Management Thread, Papercut scripting help in Technical; Could someone cleverer than me point me in the right direction for this script? I want a pop-up to appear ...
  1. #1
    clareq's Avatar
    Join Date
    Dec 2005
    Location
    Doncaster
    Posts
    707
    Thank Post
    53
    Thanked 188 Times in 124 Posts
    Rep Power
    101

    Papercut scripting help

    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.

  2. #2
    clareq's Avatar
    Join Date
    Dec 2005
    Location
    Doncaster
    Posts
    707
    Thank Post
    53
    Thanked 188 Times in 124 Posts
    Rep Power
    101
    Anyone?

  3. #3
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,002
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    Post what you have and someone will be able to modify it for you.

  4. #4
    clareq's Avatar
    Join Date
    Dec 2005
    Location
    Doncaster
    Posts
    707
    Thank Post
    53
    Thanked 188 Times in 124 Posts
    Rep Power
    101
    Thank you - the pre-defined script is:

    Code:
    /*
    * 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(
          "<html>This print job is <span style='color:red'><b>color</b></span>"
          + " and costs <b>" + inputs.utils.formatCost(inputs.job.cost)
          + "</b>.  You can save money by printing the job in grayscale.<br><br>" 
          + "Do you want to print this job?</html>",
          {"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;
        }
      }
    }

  5. #5

    Join Date
    Dec 2011
    Location
    The Hague
    Posts
    14
    Thank Post
    0
    Thanked 8 Times in 5 Posts
    Rep Power
    8
    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:

    Code:
    /*
    * 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.

  6. Thanks to Wiebbe from:

    clareq (18th July 2012)

  7. #6
    clareq's Avatar
    Join Date
    Dec 2005
    Location
    Doncaster
    Posts
    707
    Thank Post
    53
    Thanked 188 Times in 124 Posts
    Rep Power
    101
    That is perfect, thank you

  8. #7
    Big_Ted's Avatar
    Join Date
    Apr 2011
    Location
    Clevedon
    Posts
    135
    Thank Post
    1
    Thanked 20 Times in 20 Posts
    Rep Power
    10
    Small world but the tweak you suggested is going to be used by another site at the end of this week

  9. #8

    Join Date
    Jan 2013
    Location
    Belfast
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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

  10. #9
    Min
    Min is offline

    Join Date
    Jan 2013
    Location
    Bristol
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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();
    }
    }
    }

  11. #10

    Join Date
    Dec 2011
    Location
    The Hague
    Posts
    14
    Thank Post
    0
    Thanked 8 Times in 5 Posts
    Rep Power
    8
    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!

  12. #11
    Min
    Min is offline

    Join Date
    Jan 2013
    Location
    Bristol
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    good spot Wiebbe! apologies didn't look properly. i found that script works perfectly with a Ricoh PCl5 driver.

  13. #12

    Join Date
    May 2012
    Location
    Melbourne, Australia
    Posts
    15
    Thank Post
    4
    Thanked 7 Times in 4 Posts
    Rep Power
    6
    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 support@papercut.com 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.

  14. #13

    Join Date
    Jan 2013
    Location
    Belfast
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Many thanks

    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

  15. #14

    Join Date
    May 2012
    Location
    Melbourne, Australia
    Posts
    15
    Thank Post
    4
    Thanked 7 Times in 4 Posts
    Rep Power
    6
    Quote Originally Posted by kerrk21 View Post
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. PHP script help
    By FN-GM in forum Web Development
    Replies: 18
    Last Post: 19th August 2008, 02:52 PM
  2. Logon Script Help
    By djones in forum Scripts
    Replies: 17
    Last Post: 13th March 2008, 06:00 PM
  3. Proxy Authentication Script - HELP!!!!!
    By chrisa in forum Scripts
    Replies: 9
    Last Post: 7th March 2008, 04:34 PM
  4. AutoIt Script Help - Get Last Changed File
    By russdev in forum Scripts
    Replies: 8
    Last Post: 8th August 2007, 05:34 AM
  5. One PC refuses to run script! Help!!!
    By woody in forum Scripts
    Replies: 6
    Last Post: 5th October 2005, 11:37 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •