This website is no longer being maintained.
Please see the latest information at our new site.
FORMagic/400 - Form/Data Alignment Issues
Occasionally, the complex interaction between OS/400 spooling, emulators, PCL-compatible printers, user applications, and forms causes a situation where forms and data are aligned differently when printed on various printers. Fortunately, this issue does not occur very often. When it does, however, so many factors are involved that it is virtually impossible to diagnose a specific cause and correct it directly.FORMagic/400 is designed to print each form in a fixed location on the page, regardless of margins. In effect, forms are printed using the margin settings in place when the form was originally designed. It has been our experience that, when misalignment issues occur, the form actually prints in the intended location. The misalignment occurs because the data has moved, not the form. We believe the issue of varying alignment arises from obscure interactions among the settings used by spooling, the emulator, the user application, and the printer. Subtle interactions are always present, but they become far more obvious when electronic forms are introduced into the environment.
The procedure described below is intended to provide a circumvention when needed. It is fairly easy to implement, requires only that a few PCL commands be carefully employed, and represents the only reasonable solution we have seen.
The procedure uses PCL commands to set the upper left page margin (the page origin) to a fixed location and subsequently to adjust it in a manner so the data fits the form. It is intended to work on all printers, so you do not have to maintain separate programs or forms for the various alignments that occur. We cannot guarantee success in all environments, but we will support this procedure and amend it, if necessary and possible, to handle additional situations.
Considerations for Using the Print Data Relocation Commands
Several print data relocation techniques can be implemented. Using all of them together takes additional effort that is seldom necessary. Before getting into the details of the specific commands themselves, it is helpful to understand some of the higher level issues involved. This information will help you understand when specific techniques may or may not be required.Obviously, some experimentation may be necessary to get just the right combination needed to resolve your alignment problem. It is often very desirable to experiment with a copy of your production program, perhaps even substantially shortened and simplified, before making permanent changes.
Dummy Pages: We have seen occasions where misalignment is different for page one and other pages. If all pages exhibit the same misalignment, a dummy page should not be required. When misalignment does occur differently for page one and other pages, first try using the relocation commands only. If that does not resolve the misalignment, there may be no choice except to insert a "dummy" page which precedes the "real" output pages. This page should have the form, print data relocation commands, and some dummy text, perhaps the words "This page intentionally left blank. Please discard it."
Every Page vs. First Page: Sometimes, you may have to insert the relocation commands on every page. Other times, insertion on the first page only, plus the dummy page if used, will suffice. If the architecture of your program permits it easily, use them on every page. If not, try them on the first page only. If that does not resolve the misalignment, you will have to do the extra work to place the commands on every page.
Form Merge Commands: The location where you place these command(s) on the page should not matter. However, these procedures show their placement on the same line as the relocation commands, which must always be the first thing on a page. Merge commands must always follow all relocation commands.
Horizontal Misalignment: We have almost never observed horizontal misalignment. We suggest that you employ the left margin alignment commands only in those very rare cases when you actually experience horizontal misalignment.
Vertical Misalignment: We do not observe vertical misalignment very often, but this is the specific problem these procedures were actually developed to address.
Print Data Relocation Commands
The complete print data relocation command is .&l#E.9.&a#L.&a0R!.*p+#Y.&f#y3X, where the periods represent the Escape character, the Exclamation Point represents a Carriage Return, and the #'s represent values you must supply.Segregated into the individual component commands, we have:
Characters: .&l#E .9.&a#L .&a0R! .*p+#Y .&f#y3X ASCII Hex: 1B266C##45 1B391B2661##4C 1B266130520D 1B2A702B##59 1B2666##793358 Purpose: Top Margin Left Margin Row1,Col1 Vert Adj Form Merge Usage: Required Optional Required Optional Optional
- .&l#E - the Top Margin command specifies the number of unused print lines in the top margin area. Only integer values (full lines) can be used; decimals are ignored. This command is always required. If you use the typical half-inch margins, # would be 3 for 6 lpi and 4 for 8 lpi. Whatever value you specify, the next lower line becomes the first print line. You may need to experiment to determine which value causes proper alignment with your form.
- .9.&a#L - the Left Margin command specifies the number of columns to be added to the minimum possible left margin width. Only integer values (full columns) can be used; decimals are ignored. This adjustment is almost never needed. Don't use it unless you actually need a horizontal adjustment. The default for # is 0, the minimum size left margin. Whatever value you specify, it determines where print position one is located. You may need to experiment to determine which value causes proper alignment with your form.
- .&a0R! - the Move to Origin command moves the current print position to the newly established location for line 1, column 1. Note that no values are set for this command; it is always constant. This command should always be used.
- .*p+#Y - the Vertical Adjustment command is used if, after setting the top margin, the print data still needs a small downward adjustment. # is almost always measured at 300 units/inch. If any of your printers uses a value other than 300, you should not use this command. This command must be used on every page needing an adjustment; it cannot be used on the first page only. There is an equivalent command for horizontal adjustment. However, it would have to be used on every line of every page, so it is not covered here.
- .&f#y3X - the Form Merge command merges a form. You should already be familiar with it, so no further explanation is provided here.
Programming for Print Data Relocation:
First, from the information provided above, determine which command components will be used. Each component must then be translated into appropriate AS/400 ASCII hex syntax as described in the FORMagic/400 User's Guide. You should already be somewhat familiar with this process since it is used with the form merge command. Only two steps are required to finalize each command:
Always use commands in the order presented above. Exclude any optional commands you don't need. After completing each individual command, string them all together with no spaces and place the result on row 1, starting in column 1. Do not place it anywhere else; it must be the first thing on the page! However, remember the merge command can go anywhere on the page as long as it follows all of the relocation commands.
- Complete any missing values (the #'s) in the command prototypes above and translate them to ASCII hex.
- Add a two byte prefix: x'03yy' where yy represents the one byte binary length of the command (excluding the prefix). For instance, a command of length 5 would have a prefix of x'0305' and a command of length 25 would have a prefix of x'0319'.
Feedback
Please let us know when this procedure resolves an issue and when it does not. Given the unusual nature of this problem and the difficulty of identifying and finding all of the variables involved, feedback from everyone utilizing this procedure is critical toward helping us to optimize it for everyone.