Overcome the Page Control Limitations of iSeries Access Printer Emulation Sessions
May 2, 2007 Michael Sansoterra
Over the years, iSeries Access virtual printer emulation sessions have been used to successfully print a variety of spool file reports from System i and AS/400 systems to a local PC printer. Regardless of the report’s page attributes (page orientation, lines per inch, characters per inch, number of columns, etc.), the printer emulator will often successfully and automatically correct the output and automatically adjust the spool file’s page settings to print successfully to a local printer. However, in other cases it seems like it takes quite a bit of tinkering to get various spool files to print correctly to a local printer. Specifically, here are two common scenarios I encounter:
Do these scenarios sound familiar? And what about those times when you finally get a printer session to work but don’t get a good backup of the session’s definition?! Attempting to reconfigure a session that once worked is often a frustrating exercise. (Over the years, I’ve attempted to help many customers re-create printer session definitions that were lost.) When working with a PC laser printer, in many cases I believe the answer to these printer emulator dilemmas are:
If the emulator doesn’t have to guess the page format, then we need no tinkering with the page definition–in most cases the default emulator characteristics will work so we don’t need to worry about backing up the emulation session’s definition or documenting an obscure combination of settings. Further, we don’t need to lock a printer emulator into printing “landscape” only or “portrait” only printing as often occurs. The answer to removing the guess work is to correctly define page attributes on the spool file itself so the emulator knows exactly how to format the page. A spool file gets its attributes from the printer file (or from a printer file override) so the printer file definition itself is where we need to focus our attention. To illustrate the proposed solution, consider one common problem scenario:
In order to fix this problem, the printer file should be defined with the following characteristics: PAGESIZE(66 80) CPI(10) LPI(6) PAGRTT(0) The PAGESIZE parameter defines the page size at 66 lines per page and 80 characters across. The PAGRTT parameter defines the page rotation in 90 degree increments. The default page rotation is *AUTO which leaves some guesswork to the printer emulator as to how to best format the output. A page rotation of 0 will force a portrait print. A rotation of 90 will force landscape orientation. The CPI and LPI settings define the characters per inch and lines per inch. 10 CPI is the default. 6 LPI is also a default. For 11-inch length paper, 6 LPI will give us the default of 66 lines per page (11 inches per page time 6 LPI = 66 lines per page). As already mentioned, when a spool file is generated it will inherit the page settings from the printer file’s definition. When the spool file is sent to the emulator, these settings will instruct the emulator how to print the spool file without any guess work. Understanding the relationship between the physical page width and the characters per inch (CPI) is an important key to hassle free printing. For letter-sized paper (8.5-inches by 11 inches), assuming default quarter-inch margins on the right and left, there is 8 inches of printable space across the page when printing portrait. At 10 CPI, we can fit 80 characters on the page (8 inches times 10 CPI = 80 characters.) If we increase the CPI to 12, 96 characters will fit. Therefore, if you have a spool file that is 90 characters wide that you want to print portrait, you will need to increase the characters per inch setting to 12: PAGESIZE(66 96) CPI(12) PAGRTT(0) Many common printer files contain definitions with 132 characters across the page. Typically, these should print with the landscape orientation. Again, assuming letter size paper, with quarter-inch margins on each side we have 10 1/2 inches of printable space. At 10 CPI, we can fit 105 characters. At 12 CPI we can fit 126 characters–not quite enough. At 13.3 CPI (the next available CPI setting after 12), we can fit about 139 characters. (Note that printers vary in their default margin settings so this exact number may not fit.) Therefore, I usually set these printer files to use the following attributes: PAGESIZE(51 132) OVRFLW(47) CPI(13.3) PAGRTT(90) The page rotation (PAGRTT) option is set to 90 degrees for landscape and the increased CPI setting will allow a smaller font that is capable of getting all 132 characters across. Since the page is rotated, the paper is now only 8.5 inches in height and 66 lines will no longer fit. At 6 LPI, we can only fit 51 lines (8.5 inches per page times 6 LPI = 51 lines per page.) Recalling there is a margin, we will not get all of those lines on a page. The overflow line is arbitrary although it needs to be less than or equal to the page length. An overflow of 47 usually works but may need to be adjusted if there are detail or total sections that span multiple lines within a single record format in the printer file. If you need more than 132 characters across a landscape page, simply increase the CPI setting to match the necessary page width: PAGESIZE(51 165) CPI(15) OVRFLW(48) PAGRTT(90) When exceeding 15 CPI, I’ve found that it also helps to increase the LPI from 6 LPI to 8 LPI so that the height of the font isn’t out of proportion with its width: PAGESIZE(68 198) CPI(18) LPI(8) OVRFLW(62) PAGRTT(90) Please note that even though the page size is defined at 198 characters across (11 inches times 18 CPI = 198 characters) the printer margins will prevent all 198 characters from printing. I’ve even printed a large number of columns on legal size paper (8.5 inches by 14 inches) using the following settings: PAGESIZE(8.5 14 *UOM) LPI(12) CPI(20) PAGRTT(90) In this example, the page size is given in the unit of measure (inches) rather than the number of rows and columns. Since default printer margins vary by manufacturer, we may not always consistently be able to fit the expected number of characters on the page. One manufacturer’s default margins may be quarter-inch and another’s may be half-inch (although with newer printers, large default margins are no longer the problem they once were!) But, if you have problems fitting everything due to margin restrictions, changing or overriding the printer file to type of *AFPDS should allow exact margins to be specified on the printer file definition: DEVTYPE(*AFPDS) PAGESIZE(51 134) CPI(13.3) Assuming the default unit of measure is inches, the FRONTMGN parameter above forces an upper left corner margin of 0.2 inches down and 0.2 inches across. However, an *AFPDS printer file can only be printed to an *AFP (advanced function printing) capable printer or to an ASCII printer device with the host print transform option set to *YES. To print AFP spool files to a virtual printer, configure the iSeries Access printer emulator to use the Host Print Transform option (menu option Communication –> Configure –> Setup). How does one apply these printer file settings in a production environment? Setting these printer file attributes in an environment with homegrown software is as easy as specifying these parameters in the CRTPRTF (Create Printer File) command. However, purchased application software can be a special challenge. Here are a few ideas for how to proceed with canned software packages:
There is one other thing to consider. In certain cases, overriding the printer file with different page setup characteristics may be dependent on whether the user is printing to a local printer or an operator printing to, say, a line printer. In these cases, you may need to conditionally override a printer file based on user name, job name, etc. based on a presumed destination printer type. Changing or overriding printer file parameters for specific page setup characteristics is a good way to get consistent printer output. Once printer files have been defined with appropriate attributes, you’ll notice far fewer headaches with the printer emulator software!
Michael Sansoterra is a programmer/analyst for i3 Business Solutions, an IT services firm based in Grand Rapids, Michigan. Click here to contact Michael Sansoterra by e-mail.
|