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:

The following information about the document sent to print is available:

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:

For example, print multiple copies distributing the load between three printers as 20%, 30%, and 50%. That is, send a print job for 10 copies of the document to O&K Print Router, so that 2 copies are printed on HP LaserJet 9000 PCL6, 3 copies on Brother DCP-7070DW, and 5 copies on Xerox WorkCentre Pro 275. To do it, create the following printing script:
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
}