How to Deal with Auto-Rotate on Plotters and Wide-Format printers

KB Home   |   How to Deal with Auto-Rotate on Plotters and Wide-Format printers

Main.DealingWithAutoRotateOnPlottersAndWideFormatPrinters History

Hide minor edits - Show changes to output

June 30, 2017, at 01:20 AM by James V - Changes < to >
Changed lines 41-42 from:
  // if the long edge is less than the roll width, assume auto-rotate
  if (LONGEDGE < ROLLWIDTH) {
to:
  // if the long edge is more than the roll width, assume auto-rotate
  if (LONGEDGE > ROLLWIDTH) {
February 04, 2015, at 06:05 AM by Shane Higgins -
Changed line 47 from:
  actions.job.setCost(PAPERUSED * (COSTPM / 1000) * inputs.job.copies); 
to:
  actions.job.setCost(PAPERUSED * (COSTPM / 1000) * inputs.job.totalPages * inputs.job.copies); 
Changed lines 58-61 from:
!! Accounting for Copies - Early 2015

The original script did not account properly for jobs that had multiple copies. This has bee updated by modifying the following line:
to:
!! Accounting for Copies and Pages - Early 2015

The original script did not account properly for jobs that had multiple copies or pages. This has been updated by modifying the following line:
Changed lines 66-67 from:
[@ actions.job.setCost(PAPERUSED * (COSTPM / 1000) * inputs.job.copies); @]
to:
[@ actions.job.setCost(PAPERUSED * (COSTPM / 1000) * inputs.job.totalPages * inputs.job.copies); @]

'''Note:''' The script, can only base it's costing on the size of the first page, and will apply that cost to all subsequent pages.

Changed line 73 from:
[-Keywords: dealing with auto rotate, banner landscape portrait,-]
to:
[-Keywords: dealing with auto rotate, banner landscape portrait, plotter-]
Changed lines 58-59 from:
!! Accounting for Copies - Early 2014
to:
!! Accounting for Copies - Early 2015
February 01, 2015, at 11:20 PM by Jason - Updating with inputs.job.copies
Changed line 47 from:
  actions.job.setCost(PAPERUSED * (COSTPM / 1000)); 
to:
  actions.job.setCost(PAPERUSED * (COSTPM / 1000) * inputs.job.copies); 
Added lines 58-67:
!! Accounting for Copies - Early 2014

The original script did not account properly for jobs that had multiple copies. This has bee updated by modifying the following line:

[@ actions.job.setCost(PAPERUSED * (COSTPM / 1000)); @]

It now reads

[@ actions.job.setCost(PAPERUSED * (COSTPM / 1000) * inputs.job.copies); @]

Changed lines 56-57 from:
Change [@max();@] to [@Math.max();@] and [@min();@] to [@Math.min();@]. This is case-sensitive.
to:
Change [@max(...);@] to [@Math.max(...);@] and [@min(...);@] to [@Math.min(...);@]. This is case-sensitive.
December 05, 2014, at 12:12 AM by Jason - "max" is not defined.
Added lines 50-57:

!! "max" is not defined.

If you receive the following error:
%red%[@Error in "printJobHook" - ReferenceError: "max" is not defined. (printer-script#28)@]%red%

Change [@max();@] to [@Math.max();@] and [@min();@] to [@Math.min();@]. This is case-sensitive.

Changed lines 3-6 from:
PaperCut has a wide range of [[SupportedPrinters|supported printers]], ranging from entry level 6ppm inkjets to 100+ enterprise photocopiers. We also support many Plotters and Wide-Format printers with our [[https://www.papercut.com/products/ng/manual/ch-printer-mgmt-diff-charging.html|advanced charging]].

However, many newer Wide-Format printers have the ability to auto-rotate once the print job has been sent to the printer. This means that when charging "by length" that users may not be charged the correct amount.
to:
PaperCut has a wide range of [[SupportedPrinters|supported printers]], ranging from entry level 6ppm inkjets to 100+ppm enterprise photocopiers. We also support many plotters and wide-format printers with our [[https://www.papercut.com/products/ng/manual/ch-printer-mgmt-diff-charging.html|advanced charging]].

However, many newer wide-format printers have the ability to auto-rotate once the print job has been sent to the printer. This means that when charging "by length" that users may not be charged the correct amount.
Changed lines 9-10 from:
'''Note:''' This script requires testing in your environment as some print drivers will rotate the page, others will rotate the image. Drivers that rotate the image but not the page may not detect accurately. If this is the case in your environment we would recommend charging per-area rather than per-length.
to:
'''Note:''' This script requires testing in your environment as some print drivers will rotate the page, others will rotate the image (raster). Drivers that rotate the image but not the page may not be detected accurately. If this is the case in your environment we would recommend charging per-area rather than per-length.  Our developers are looking into how to detect image auto-rotation.
Changed lines 9-10 from:
'''Note:''' This script requires testing in your environment as some print drivers will rotate the page, others will rotate the image. Drivers that rotate the image but not the page may not detect accurately.
to:
'''Note:''' This script requires testing in your environment as some print drivers will rotate the page, others will rotate the image. Drivers that rotate the image but not the page may not detect accurately. If this is the case in your environment we would recommend charging per-area rather than per-length.
Added lines 9-10:
'''Note:''' This script requires testing in your environment as some print drivers will rotate the page, others will rotate the image. Drivers that rotate the image but not the page may not detect accurately.
Changed line 53 from:
[-Keywords: -]
to:
[-Keywords: dealing with auto rotate, banner landscape portrait,-]
Changed line 47 from:
&#8203;@]
to:
@]
Deleted lines 18-20:
  var ROLLWIDTH = 914;  // 36" in mm. 
  var COSTPM = 3.28; // Cost per meter
 
Changed lines 32-40 from:
  if (inputs.job.paperSizeHeightMM > inputs.job.paperSizeWidthMM)  { // portrait
 
  if (inputs.job.paperSizeHeightMM < ROLLWIDTH) { // height is less than roll width, assume auto-rotate
      var COST = inputs.job.paperSizeWidthMM *
(COSTPM / 1000);
      actions.job.setCost(COST);
 
  }
    else { // height is equal or greater than roll width, assume no rotate
 
    var COST = inputs.job.paperSizeHeightMM * (COSTPM / 1000);
     actions.job.setCost(COST);
    }
to:
  var ROLLWIDTH = 914;  // 36" in mm. 
  var COSTPM = 3.28; // Cost per meter
 
  // Now find long edge and short edge
  var LONGEDGE = max
(inputs.job.paperSizeHeightMM, inputs.job.paperSizeWidthMM);
  var SHORTEDGE = min(inputs.job.paperSizeHeightMM, inputs.job.paperSizeWidthMM);
 
  // if the long edge is less than the roll width, assume auto-rotate
  if (LONGEDGE < ROLLWIDTH) {
    var PAPERUSED = LONGEDGE;
  } else { // assume long edge fits across roll, charge by short edge
    var PAPERUSED = SHORTEDGE;
Changed lines 45-55 from:
  if (inputs.job.paperSizeHeightMM < inputs.job.paperSizeWidthMM)  { // landscape
    if (inputs.job.paperSizeWidthMM > ROLLWIDTH) { // width is greater than roll width, assume auto-rotate
      var COST = inputs.job.paperSizeWidthMM * (COSTPM / 1000)
;
      actions.job.setCost(COST);
    }
    else { // width is equal or less than roll width, assume no rotate
      var COST = inputs.job.paperSizeHeightMM * (COSTPM / 1000);
      actions.job.setCost(COST);
    }
  }
}
@]
to:
  actions.job.setCost(PAPERUSED * (COSTPM / 1000)); 
}
&#8203
;@]
Added lines 1-59:
(:title How to Deal with Auto-Rotate on Plotters and Wide-Format printers:)

PaperCut has a wide range of [[SupportedPrinters|supported printers]], ranging from entry level 6ppm inkjets to 100+ enterprise photocopiers. We also support many Plotters and Wide-Format printers with our [[https://www.papercut.com/products/ng/manual/ch-printer-mgmt-diff-charging.html|advanced charging]].

However, many newer Wide-Format printers have the ability to auto-rotate once the print job has been sent to the printer. This means that when charging "by length" that users may not be charged the correct amount.

By using PaperCut's [[https://www.papercut.com/tour/advanced-scripting/|Advanced Printer Scripting]], you can override this behaviour with the following script which will charge based on some simple decisions about whether the print job is longer than wide and whether auto-rotate can still happen.

[@/*
* Charge based on short length for Auto-Rotating printers.
*
* Some wide-format printers will auto-rotate print jobs
* to save paper. This script will charge based on short
* edge if the long edge is less than a defined length.
*/

function printJobHook(inputs, actions) {
 
  var ROLLWIDTH = 914;  // 36" in mm. 
  var COSTPM = 3.28; // Cost per meter
 
  /*
  * 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.paperSizeHeightMM > inputs.job.paperSizeWidthMM)  { // portrait
    if (inputs.job.paperSizeHeightMM < ROLLWIDTH) { // height is less than roll width, assume auto-rotate
      var COST = inputs.job.paperSizeWidthMM * (COSTPM / 1000);
      actions.job.setCost(COST);
    }
    else { // height is equal or greater than roll width, assume no rotate
      var COST = inputs.job.paperSizeHeightMM * (COSTPM / 1000);
      actions.job.setCost(COST);
    }
  }
  if (inputs.job.paperSizeHeightMM < inputs.job.paperSizeWidthMM)  { // landscape
    if (inputs.job.paperSizeWidthMM > ROLLWIDTH) { // width is greater than roll width, assume auto-rotate
      var COST = inputs.job.paperSizeWidthMM * (COSTPM / 1000);
      actions.job.setCost(COST);
    }
    else { // width is equal or less than roll width, assume no rotate
      var COST = inputs.job.paperSizeHeightMM * (COSTPM / 1000);
      actions.job.setCost(COST);
    }
  }
}@]
----
''Categories:''
----
[-Keywords: -]

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on June 30, 2017, at 01:20 AM
Printable View   |   Article History   |   Edit Article