User scripts for O&K Print Router
Starting from version 3.00, O&K Print Router supports user scripts for faster printing and balancing load between multiple printers. The scripts are written in Chaiscript. For more details about this programming language, please visit the ChaiScript official website.
When a document is sent to a printer controlled by O&K Print Router, first the document printing and document forwarding rules defined via the Redirect options are processed. Then O&K Print Router executes the Custom Script if one has been defined:
You can use the following functions in your scripts:
Print("Printer name", Number_of_Copies)
– Print the specified number of copies of the document on one printer.PrintMultiply(Printers_List, Number_of_Copies)
– Print the specified number of copies of the document on ALL printers from the list.PrintBalanced(Printers_List, Number_of_Copies)
– Print the specified number of copies of the document on THE MOST AVAILABLE printer from the list.PrintPages(Printers_List, PaperSize, Color, Number_of_Copies, PrintingMode)
- Printing several pages from the document to ALL printers from the list.
Page will be print if its parameters are correspond with function arguments PaperSize и Color.
PaperSize: A4, A3 and other paper size names.
PaperSize: 1 - black & white printing. 2 - color printing.
PrintingMode: 0 - print by paper size, 1 - print by physical pages dimensions. For example if it is a plot draw.
The following information about the document sent to print is available:
- DocName – The document’s name.
- Pages – The number of pages.
- Copies – The number of copies.
- Color – Color printing mode; 0 – monochrome printing, 1 – color printing.
To define user printing rules, open the Custom Script tab, copy and paste (or type in) your script, and save it. To validate the syntax, click the Test button. (In the test mode, the document will not be actually printed.)
Use cases.
Print a document on different printers depending on paper size:
var printers = VectorOfString() // Variable for printers list if (PaperSize == "A4") // If paper size is "А4" { // Add printer to the list printers.push_back("HP LaserJet 9000 PCL6") printers.push_back("Microsoft XPS Document Writer") // Print document on THE MOST AVAILABLE printer with 1 copy PrintBalanced(printers, 1) } else // If paper size is NOT "А4" { // Print document on the printer with 1 copy Print("Microsoft XPS Document Writer", 1) }
Print a document on different printers depending on color printing mode:
var printers = VectorOfString() // Variable for printers list if (Color == 1) // If documnt is color { // Add printer to the list printers.push_back("HP LaserJet 9000 PCL6") printers.push_back("Microsoft XPS Document Writer") // Print document on ALL printers with 1 copy PrintMultiply(printers, 1) } else { // Print document on the printer with 1 copy Print("Microsoft XPS Document Writer", 1) }
Print different numbers of copies of a document on different printers:
if (Copies > 1) // If document is more than 1 { var copies1 = Copies * 0.2 // Get 20% copies Print("HP LaserJet 9000 PCL6", copies1) // Print 20% copies var copies2 = Copies * 0.3 // Get 30% copies Print("Brother DCP-7070DW Printer", copies2) // Print 30% copies var copies3 = Copies - copies1 - copies2 // Get 50% copies Print("Xerox WorkCentre Pro 275", copies3) // Print it on third printer } else { Print("Xerox WorkCentre Pro 275", Copies) // If number of copies is 1 - print document on this printer }
Printing pages from a document depending on color mode or/and paper size:
var printersA4 = VectorOfString() // Variable for printers list printersA4.push_back("HP LaserJet 9000 PCL6") // Add printer to the list PrintPages(printersA4, "A4", 0, 1, 0) // Print all А4 pages with any color mode in 1 copy var printersA3 = VectorOfString() // Variable for printers list printersA3.push_back("Xerox WorkCentre 6015N") // Add printer to the list PrintPages(printersA3, "A3", 1, 3, 0) // Print all B&W А3 pages in 3 copies. PrintPages(printersA3, "A3", 2, 2, 0) // Print all color А3 pages in 2 copies. var printers = VectorOfString() // Variable for printers list printers.push_back("HP Designjet T795 44in HPGL2") // Add printer to the list PrintPages(printers, "", 0, 1, 0) // Print all remaining pages in any color and paper size in 1 copy
Print the document on different printers depending on the document name:
if (DocName.find("sample text") == 0) // Document name starts with "sample text" { Print("printer1", 1) // Print document to printer1 with 1 copy } if (DocName.find("sample text") != size_t(-1)) // Document name contains "sample text" { Print("printer2", 1) // Print document to printer2 with 1 copy } if (DocName.find("sample text") == size_t(-1)) // Document name doesn't contain "sample text" { Print("printer3", 1) // Print document to printer3 with 1 copy }