16 Nov 2011
In this post I am going to try and explain the concepts behind the scripting support in Print Distributor. I will cover what it is, how it interacts with your print jobs and what you can achieve with it.
Print Distributor has a Script action that will let you run a script before or after any other actions in your configuration. You can also include it in the global actions if you have a script that needs to run across many virtual printers. VBScript is also used for the expressions you enter for conditional actions. When a print document arrives at a Print Distributor virtual printer there are two files created, a raw file and a job file. The raw file is the data the printer receives, typically this is a PostScript or PCL file but may be in another format. The job file contains attributes about the document such as the name of the user who printed it and the document name. Your scripts have access to both of these files to varying degrees. The job attributes are mostly associated with the administration of the printer, these include the user name, document name, priority, machine name, print date, printer name, size, job id and so on. All of these attributes can be modified and on the whole they won’t change the printed job but may change the behaviour of subsequent actions.
A typical example where you might modifiy a job attribute is if you are archiving files by the Document Name field but the formatting isn’t quite right for your requirements. For instance if the application that is printing used underscore characters instead of spaces you could replace the underscores with spaces in your script.
As well as the job attributes there are a number of document attributes that indicate some of the printer settings. These give you access to the paper source, paper size, duplex, colour and orientation. This is read only access as the real printer controls are in the raw file. It can be useful for routing documents or accounting, for instance you may pick out all the A3 / B sized documents and route them to a printer with a large size paper input or route all the colour prints to a colour printer.
It is also possible to read the raw print file in a script. Most PCL and PostScript files will have a header that is plain text and some times you can extract useful information about the document when that isn’t available in the job. A very common use for this is reading the document name when the document has been spooled from a mainframe or UNIX system.
There are also a number of control mechanisms available to a script, it is possible to abort the document, reprint from within the script or send a message to the log. You can also check the status of previous actions, for instance you can check for errors, find the last printer the load balancing action used or the exit code from the Run Program action.
I hope this has given you an idea of some of the capabilities of scripting in Print Distributor. If you want to investigate the scripting in Print Distributor then the help file has further information or if you don’t want to get your hands dirty then contact us and we will do what we can to help.