This is an example of a 132-column untagged text file. There are formfeeds every 66 lines, so Print Wizard will attempt to fit 66 lines to the page. Note that if a file contains only one formfeed, Print Wizard does not consider that legitimate. ------------------------------------------------------------------------------ Print Wizard is a body of logic that figures out how to print text data in an environment where the printer being used has a great deal of flexibility in font sizing, text positioning, line spacing, page margins, etc. Print Wizard logic has been implemented in the passthrough print channel of AnzioWin, a terminal emulation program (telnet client) from Rasmussen Software. Also in AnzioWin, it can be used with the PRINTFILE command to print a DOS-based text file. Print Wizard has also been implemented as a freestanding Windows program capable of printing a wide variety of text files. A Windows-based LPD (Line Printer Daemon) is under development. Future implementations will be as a UNIX-based filter program, which will allow Print Wizard's capabilities to be used on UNIX system printers, and as a Windows DLL. THE FIRST PROBLEM - LEGACY DATA ON A MODERN PRINTER Many programs generate print data that is at the lowest common denominator: lines of text separated by Carriage Return/LineFeeds (CRLFs). There may be FormFeeds (FFs), or there may be an assumption built in about page length. There may be 80 characters per line or there may be 132, or some other number. There may be tabs, backspace-bolding or backspace-underlining. There may be an assumption of 6 lines per inch or 8 lines per inch. Finally, there may be embedded control codes for a particular printer type, to do initialization, for instance. This print data may be being generated anew, or it may be contained in a "printfile" stored on disk. The user needs to print this data. But the user has a 600-dpi laser printer. It can print in any font, in any size, in any orientation, with any margins, with any linespacing, in any character set. Something has to tell that printer how to deal with a raw data stream. THE SECOND PROBLEM - LEGACY PROGRAMS THAT WANT TO FLY System designers, writing programs in a database language, COBOL, BASIC, etc. would like to take advantage of modern printers' capabilities, but don't have a way to do so. There are hundreds of printer types available, and it seems unwise to tie oneself to a particular model, especially hardcoded into the source program. What is needed is a device-independent way to drive high-end printer features. Items to be controlled start at the job level, with such things as paper size and orientation, margins, line spacing, and character size. They can continue through simple text style changes (bold, italic) to drawing lines, rectangles, and gray bars. At the high end, one could include bitmaps, forms overlays, and barcodes. Many elements would need to be positioned precisely on the page. ANZIO'S STANDARD PRINTING AnzioWin's standard printing is selected by turning Print Wizard off (in Anzio Lite, Print Wizard is always off). In this mode, the user has pre-selected a printer, paper size and orientation. If the user selects Low-level Print, then data to be printed is sent to the printer at a very low level. If the print data contains control codes specific to that printer type, these will be obeyed, to do such things as setting font and line spacing. In the absence of these, the printer will use its defaults. If Low-level Print is off, the user can also select a font and font size. The font size (in points) is actually the height, and it dictates both the font width and the line spacing. These in conjunction with the printable region of the paper (as indicated by the Windows printer driver) determine characters per line and lines per page. Anzio will automatically wrap long lines; it will cause page breaks when advanced beyond end of page; it will also deal with the control characters: Formfeed hex 0C Advance to next page Return hex 0D Carriage Return Linefeed hex 0A Down one line Tab hex 09 Every 8 spaces Backspace hex 08 Back up one space Backspace is used in some data streams, such as from UNIX "man" pages, to do overprinting for bold and/or underline. Anzio will translate these into actual bold and/or underline fonts. PRINT WIZARD PRINT WIZARD, PHASE ONE Phase One of Print Wizard was introduced in AnzioWin version 10.9. The goal was to handle in a reasonable manner a wide variety of types of print data being passthrough-printed from the host system. This had the effect of removing from the user the responsibility of making certain decisions before executing a print job. The user always must indicate a printer to be used, a paper size, an orientation (portrait or landscape), and a font. With Print Wizard turned on, however, the user no longer needs to be concerned with font size or Low-level Print. Print Wizard does not start printing text as soon as it is received. Instead, several hundred lines are stored in a buffer so they can be analyzed. Print Wizard first determines whether the data stream a) is PostScript, or b) contains Escape codes. If either of these is true, it sets the low-level print flag, and all print data is sent to the printer at a very low level. If the data gets past that test, it is analyzed to determine the maximum number of characters in a line, while watching for necessary tab expansion and backspace processing. Then, the buffer is checked to determine whether there are formfeeds in the data, and if there are, what the maximum number of lines per page is. Print Wizard then checks with Windows to determine the printable area of the page in each direction. With all this information available, the Print Wizard determines page margins, character size, and character spacing in both directions. It does this using certain rules of reasonableness and conventionality. For instance, a character pitch of 25 character per inch is not reasonable. Likewise, if the document can fit using the conventional 10 cpi spacing, Print Wizard will do so. Once these parameters are determined, Print Wizard outputs the text, using the same logic as described above for line breaks, page breaks, and handling of formfeeds, tabs, etc. The result of this logic is that Print Wizard will automatically handle: 1) a PostScript file; 2) a print stream with embedded escape codes; 3) an 80-column report; 4) a 132-column report; 5) a 66-line report on a laser printer that has a half-inch unprintable area; and 6) a report that has no formfeeds. PRINT WIZARD, PHASE TWO Phase two of the Print Wizard is implemented starting in AnzioWin 11.0, and in the separate Windows program PrintWiz, version 1.0. It adds the ability for the data stream to contain certain markup tags, to precisely control the Wizard's printing, regardless of printer type. In designing an approach to precise printing, several considerations were made. First, it was important that existing data streams would be passed through without interference. Second, it was recognized that, given the various programming environments, it was important to use all standard text characters, rather than control codes or hex numbers. Finally, the coding scheme should be reasonably easy to read and understand by both the original programmers and by maintenance programmers viewing it later. An approach was adopted that involves a variation of the HTML language used in the World Wide Web. Its syntax is documented, logical, and mnemonic. It has a great deal of power, increasing rapidly. Some extensions were necessary, however, because HTML did not provide ways to be very precise, whether in placement of text or graphic elements on the page (actually, there's no vertical page in HTML), or in specifying text size. That is, HTML allows one to specify text size "1", but not "12.5 point with a 10 cpi spacing". As mentioned above, it is critical that existing data streams be able to work in this environment. More to the point, it is possible to add some tags at the beginning of the print stream, and leave the body of the report alone. HTML tags start with less-than ('<'). The ampersand ('&') also has special meaning. But an existing report may contain these characters, and it would be very difficult to deal with them in, say, a COBOL program. The solution to this issue was found in some rather obscure, but nevertheless defined, HTML tags: PLAINTEXT, XMP and LISTING. Once a document has been placed in PLAINTEXT mode, no other tag processing is done. XMP and LISTING each allow only their respective end-tags. So let us assume a program is generating a report on UNIX. Through a simple shell command, we can stick into the front of this data stream some HTML to force landscape mode, 132 columns, and 6 lines per inch, then end with a PLAINTEXT tag (which would be followed by our raw data). This combined data stream could then be piped to a passthrough print routine to AnzioWin, and the report would come off properly regardless of our printer type. PRINT WIZARD'S HTML As stated earlier, Print Wizard's markup language is based on standard HTML. A book on HTML may be useful to those new to this coding concept. Standard HTML is ambiguous about placement of text, images, etc., using units of pixels. Print Wizard, however, is designed to allow precision, and pixel size varies from printer to printer. Likewise there is an issue of how large to print a bitmap. Print Wizard takes the following approach. Each document starts off with an assumption of a virtual pixel density of 120 dots per inch (DPI). This is similar to the density used by various browsers when they print. If Print Wizard encounters a tag, which is non-standard HTML, it then assumes a DPI of 720, and a density for images (IMG-DPI) of 300. Thus bitmaps that are scanned at 300 DPI will print in true size, regardless of the printer's capabilities. Finally, within wither the tag or the tag, DPI can be set with a DOTSPERINCH attribute, and IMG-DPI can be set with an IMGDOTSPERINCH attribute. Thus if DPI is 720, then a DOT unit is 1/720 of an inch. Likewise, IMG-DPI determines the size of an IMG-DOT. If a tag places a rectangle at X=360, and DPI is 720, then the rectangle is placed 1/2 inch in from the edge of the page (Print Wizard accounts for printable area offsets in all placements). Standard special characters encoded with an ampersand ('&') are supported. Because of Print Wizard's focus on legacy data, it is not yet fully compatible with generic HTML code. Many capabilities of standard HTML have not yet been implemented, including free-form text, tables, and GIF bitmap files. Following are the tags and attributes supported by Print Wizard version 1.1c and AnzioWin version 11.1c. Items marked with a '+' are extensions to the HTML standard - they may be entire tags or specific attrinutes. Where units are involved the table shows which dot size is used, DOT or IMG-DOT, as explained above.