How
to Control Windows Printing without User Interaction
A Scenario
Different types of document have to be
printed on different types of paper. Coloured pages, headed pages,
high quality paper or flimsy stuff were all loaded into different
printers (or at least different bins). And the right kind of
document has to come out on the right kind of paper. Which means
directing the print run to the correct print queue.
In this situation, one would ideally
use a dialogue box to ask the user which printer was required. But
what if all printing has to take place at night?
UNIFACE is not much help with this.
Under UNIX one can define different Print Job Models with various
Queue settings, and activate them directly using proc code like:
print
print_job_model_name
But under Windows, the world fell
apart. Compuware gave the following instructions:
To print from Windows, put
P_MSWIN3 (or P_MSWINX for enhanced printing) in the Device Type of
your Print Job Model.
Then put PRINTMAN in the Queue field.
Doing this gives rise to the kind of
Print Job Model below:
Print Manager will present a dialog box
asking which printer to access. But there’s little point to this
for an overnight run, or in a genuine batch application with no
interaction possible.
The Solution
In any UNIFACE Print Job Model there is
a Print Options field. By using two new options /nodialog
and /queue
(available since UNIFACE 7.1.04), you can
define a model that prevents the usual Windows print dialog box
appearing and, if necessary, redirects printing to a non-default
Windows printer. (Note that /queue
implies /nodialog;
they are never entered together.)
/nodialog
Function: Disables the appearance of
the printer dialog
/queue=
logical_printer_name
Function: Redirects the print run to
a network printer corresponding to logical_printer_name
To define a logical printer, choose
Setup from the UNIFACE system menu and select the Printer page.
Imagine a scenario where you have two
reports, one has to be orientated to landscape and the other needs
to be orientated to portrait. This can be achieved by defining two
print job models (e.g. LANDSCAPE and PORTRAIT) and change the device
mode to ‘mode 1’ for landscape and ‘mode 0’ for portrait. By
using different modes there is the option to scale the printing. If
there is the need to print to a different scale the device
translation table will need to be altered. The best way to do this
is to copy P_DEFAULT from the USYS library to a user defined library
and then follow the instructions in the device translation table.
One final point:
The logical printer definitions are
stored in the Registry. Therefore they have to be defined on every
machine needing to use them. The Registry Settings are:
For UNIFACE 7.1
HKEY_CURRENT_USER/Software/Compuware/UNIFACE/<windows
dir>/usys71.ini
For UNIFACE 7.2
HKEY_CURRENT_USER/Software/Compuware/UNIFACE/<UNIFACE install
path>/USYS.ini
|