Printing to a specific Windows printer



Some reports need to be sent to a certain printer because the report requires a particular type of form or requires the special capabilities of a certain printer.


Getting Started with ACUCOBOL-GT

Version 8.0

Chapter 2: Windows Installation > 2.5 Printing and Spooler Issues > 2.5.1 Spooler Formatting > -Q <printername>

If it is desirable to utilize the Windows spooler to format report pages, but a particular printer need to be used, assign the print file to:

PRINTER1 -Q \\printername

in the configuration file ("CBLCONFI"). Printername is the printer designation as given in the Printers folder under Settings in the Start menu. The name may be up to 80 characters long and contain embedded spaces. The name may not include the semicolon character (;) or be surrounded by single or double quotes. The pages are printed in the manner described in "-P SPOOLER" above. The sample programs "graphprn.cbl" and "prndemox.cbl" contain examples of these functions.

To determine a valid printername, use the WIN$PRINTER library routine to obtain the name of the desired printer. (This is described in Appendix I under the WINPRINT-SET-PRINTER operation code in "Specifying a Printer.") Then add the following line to the program code:

MOVE "-Q \\printername" TO WS-PRINTER-NAME.

When the runtime opens a file assigned to "-Q <printername>" it sets the Windows print spooler to use this printer. The printer driver must be installed on the computer from printing is done. If printername is not recognized by the runtime, a dialog box allows a printer to be chosen manually.


Note: If access to a printer is specified using a UNC path, printing directly to the printer must be done by defining PRINTER as "-D PRN". However,be aware that this does not prevent other programs from printing at the same time possibly resulting in intermixed pages.  Also, when using the UNC path, Windows formatting is not supported.


Setting Options

It is also possible to use "-Q <printername>" to set several other printing options in the configuration file using the following syntax:

<-Q printername>[;option1=x][;option2=x][;option3=x]...

The following options may appear in any order. Options not supported by the printer driver are ignored. Printername should appear as shown in WINPRINT-NAME, but the options are case insensitive.


Note: The options PITCH, COLS, LINES, and FONT are all mutually dependent. Omitting one or more of these options may cause the resulting printout to look wrong. -------------------------------------------------------------------------------


Setting DIRECT to "ON" will cause the job to print as if the configuration file was set to "-P SPOOLER-DIRECT" (described in section 2.5.2). This will also disable any use of additional options. Setting DIRECT to the default of "OFF" causes the job to print to the selected printer as if the configuration file was set to "-P SPOOLER".


Use FONT to specify a single font name. The font name may have embedded spaces, but may not contain double or single quotes. If the font does not exist, the closest matching font is chosen.

The runtime does not align columns. If you are printing a report containing columns, use a fixed-width font.


This value specifies the point size of the font. Pitch does not determine the number of characters per line. If you use a larger pitch, the characters simply appear more crowded. For example, when printing 132 columns, a pitch of 10 will produce better character spacing than a pitch of 12.


Specifies the number of columns (width) on the page. This number is not validated by the runtime or the spooler. Choose a number of columns that coordinate with the selected font and pitch when designing the report layout.


Specifies the lines (rows of characters) on the page. This number is not validated by the runtime or the spooler. Choose a number of lines that is compatible with the selected font and pitch when designing the report layout.


If the chosen printer supports this feature, ORIENTATION allows the specification of LANDSCAPE or PORTRAIT orientation for the report. The default value of ORIENTATION is driver specific.


If the chosen printer supports this feature, COPY allows the specification of the number of copies to print.


To use the Windows spooler with an HP Laserjet printer driver located on SERVER1, and specify the font, font size, width and number of lines in the report, enter the following into CBLCONFI:

PRINTER1 -Q \\SERVER1\HP Laserjet IV;FONT=Times New Roman;PITCH=12;COLS=132;LINES=65.

To print three copies directly to the printer on a server named GUTENBERG in Landscape orientation, enter the following into CBLCONFI:


Old KB# 2671
Comment List