Printing - Directly controlling Windows printer formatting

0 Likes

Problem:

For some reports it is desirable to directly control the format of the printout using embedded control codes from a printer control language (PCL) or page description language (PDL).

Resolution:

Getting Started with ACUCOBOL-GT

Version 8.0

Chapter 2: Windows Installation > 2.5 Printing and Spooler Issues >

2.5.2 Direct Control

If it is desirable to control the format of the printout by directly using embedded control codes, simply assign the print file to "-P SPOOLER-DIRECT" or to "-Q <printername>" using the "DIRECT=ON" option. For example, to assign the print job "PRINTER1" to the spooler and retain direct control over formatting, enter the following line in your COBOL configuration file ("CBLCONFI"):

PRINTER1  -P  SPOOLER-DIRECT

Or, use the following command to assign PRINTER1 to the spooler for printing to a specific printer while retaining direct formatting control:

PRINTER1 -Q printername;DIRECT=ON

Both of these methods cause the print job to be sent to the printer via the Windows spooler, but the program does not use the spooler to format the pages. Embedded control codes must be used to handle formatting (much as would be under UNIX if the UNIX spooler is used).

When using the "-P SPOOLER-DIRECT" option, the WIN$PRINTER library routine may be used to choose a printer. However, since direct control of the printer is being handled through embedded control codes, the various options provided by WIN$PRINTER are ignored. For example, WIN$PRINTER does not set the page size, page orientation, or font. Information returned from WIN$PRINTER, such as number of lines and columns on the page, may not be accurate and should not be used. This subject is discussed in detail in Appendix I "Library Routines" of the ACUCOBOL-GT manual set.

Because some print drivers do not flush the last page, be sure to end the last page with a form-feed (for example, WRITE ... BEFORE ADVANCING PAGE). This ensures that all pages are printed. The ACUCOBOL-GT runtime ensures that no extra blank pages are printed at the end.

If the program has been coded WRITE...AFTER ADVANCING PAGE instead of WRITE...BEFORE ADVANCING PAGE, a blank last page may result. This is because a blank line written on the new page causes the Windows subsystem to flush the page for some print drivers. ACUCOBOL-GT ensures that entirely empty lines are not sent to the device (only the form-feed will be sent). But it is essential that:

1.  the program specified trailing space removal in the COBOL code (the default for print files).

2.  the configuration option MIN-REC-SIZE to "0" has been set.

The other option is to specify WRITE... BEFORE ADVANCING PAGE to avoid this potential problem.

If the user looks for the job in the spooler, it is named with the current title of the ACUCOBOL-GT window.

Old KB# 2673
Comment List
Related
Recommended