PAGE ASCII document printer $Revision: 1.11 $ Copyright (c) 1991-92 Trumphurst Ltd. ________________________________________________________________________________ File page.doc Page 1 Trumphurst Ltd. The Willows St. Martins Moor Oswestry Shropshire SY10 7BH England Tel: (+44) 0691-670318 Fax: (+44) 0691-670316 Mail: page@trmphrst.demon.co.uk <- Preferred nikki@trmphrst.demon.co.uk nikki@cix.compulink.co.uk ________________________________________________________________________________ File page.doc Page 2 PAGE ASCII document printer This is a little program I wrote to print ASCII documents and program listings. It works out sensible pagination for documents and C source files, and it will also print multiple pages side by side in landscape mode on a suitable printer, either consecutively, or in the correct order for centre-stapling to make a booklet. It is command-line and configuration file driven, so it is suitable for placing in batch files for unattended operation. As well as tidying up listings of programs and long documents, this program will also enable you to save paper - various configurations allow up to 5 normal 66-line pages to fit on each side of an A4 sheet. With the configuration files provided, this program can replace both BOOKLET and 8P (two other paper-saving programs). The program will endeavour to break pages at the largest gap (sequence of blank lines) it can find in the last third of the page. It will never place a page break between two lines that contain graphic characters (unless the whole page contains graphics). For C files, lines with "}" in the first column (or "};" in any column) are treated like a gap of 3 lines. The program also omits empty lines at the start of any page. To include blank lines anyway, just use lines containing one or more spaces. The program can also understand special character sequences of your choice to set escape sequences to your printer - e.g. bold, underline etc. In these escape sequences, the tilde character (~) is used to indicate control characters. For example, ~A indicates Ctrl-A (ASCII value 1), ~[ indicates Escape (ASCII value 27) etc. Special sequences at the beginning of a line can be used to indicate heading levels. Heading level sequences are used to indicate preferred page breaks (level 0 is equivalent to 1 blank line, level 3 to 4 blank lines), and also to send escape sequences to the printer for the heading. Usage :- page [-options] sourcefile ... Options are :- -a Append output to end of file. Normally, the output file (if specified) is truncated. This switch makes PAGE append its output on to the end of the file. -c Files are C source code. -h Print header at top of each page. -f Print footer at bottom of each page Headers and footers contain the file name (on the left) and the page number on the right. They are separated from the text by a horizontal line. -F Use form feeds between pages. ________________________________________________________________________________ File page.doc Page 3 -r Remove form feeds from input files. -b Print on both sides of the paper. The odd numbered pages will be printed first. Once all the odd pages are printed, you are prompted to feed the paper back into the printer. N.B. This option assumes you have a sheet feeder - you only need to turn the stack of paper over, and feed it straight back into the printer - the LAST page will be printed first. -B Print in booklet form for binding. The pages will be printed in the correct order for stapling into a booklet. If the number of columns (-l) is not specified, then there will be 2 pages of one column each on each side of the paper. If the number of columns is greater than two (it must be even) then it controls the number of columns on each sheet of paper - there will be half that number on each page of the booklet. -n Continue page numbering across files. Normally, page numbering restarts for each new file processed. This switch makes the page numbers continue consecutively for the whole print. -N Network print spooler in use. If you are using a network print spooler for double-sided printing, PAGE needs to close the print file between jobs to force the first sides to be printed, and then reopen the file, set up the printer, and download any fonts again. If you are not using a network spooler, PAGE can save time by merely flushing the printer output between sides. -S Sort file names into alphabetical order. Normally, files are printed in the order they are specified on the command line. If an ambiguous file name is given, they are printed in the order in which PAGE finds them in the directory. This switch will sort all the file names into alphabetical order before printing. -o Send output to file , not lpt1 -t Expand tabs to [1 <= <= 20] -l Print adjacent pages across each output page -g Leave blank columns between such adjacent pages. These options enable you to print two A5 pages side by side on each A4 sheet in landscape mode, or to print labels etc. You need a suitable configuration file to set your printer into landscape mode, though. -p Place lines on each page -m Leave a bottom margin of So you can skip over perforations in listing paper, or gaps between labels. -i Indent lines by characters (e.g. for stapling). If booklet mode is on (-B), then the indent will be left each side of the centre of each sheet. ________________________________________________________________________________ File page.doc Page 4 -w Page is characters wide -C Print copies. Each page will be printed times. -u Use character as underline character for headers/footers. -d Download font contained in .FON to printer -T Translate every occurrence of in the printed files to . This switch is usually used in a configuration file. It enables the sending of printer escapes (e.g. bold, underline) without messing up the formatted output. The translation string may contain ~ control characters. PAGE assumes that the string will take up no space on the page. -T As -T above, but the translation string is assumed to take up character positions on the page. -H [ ] Occurrences of AT THE START OF A LINE in the printed files indicate that the line is a heading level (1 <= n <= 4). PAGE then treats the line as if it had +1 blank lines before it, for determining where to break the page. / are optional escape sequences at start/end of heading. These may be used (e.g.) to underline or embolden different levels of heading. This option is best used inside a configuration file (see -s), so that PAGE does not get confused between and the next parameter. -s Use .PAG as configuration file Initial lines in beginning with '-' may contain any of the above options (except -s). A semicolon (;) anywhere in an option line indicates that the rest of the line is a comment. The first line NOT beginning with '-' is output to the printer before any text (to set up the printer). The following line is output after all text (to reset the printer). You can supply multiple source files, and/or use wild cards. You can set these options on the command line (highest precedence), in a configuration file, or using environment variables (lowest precedence). Only certain options can be set using environment variables :- Environment Variable Option Example TABS -t set TABS=4 PAGE -p set PAGE=60 PREFIX -s set PREFIX=C:\LANDSCAPE WIDTH -w set WIDTH=132 ________________________________________________________________________________ File page.doc Page 5 Six sample configuration files and one font file are provided :- File Printer LANDSCAPE.PAG LaserJet Print 2 A5 pages on each A4 sheet LIST.PAG LaserJet Use Line Printer font (118x85) TINYFONT.PAG LaserJet Download FONT.FON - 2 pages 166x80 on A4 sheet BOOKLET.PAG LaserJet Print in booklet form PAGE.PAG LaserJet Config with translation & headings to print this document PAGEDUMB.PAG Any printer Like PAGE.PAG, but for dumb printers You may need to change the number of lines per page FONT.FON LaserJet Font file for download - gives 166x181 PRINTDOC.BAT Any printer Print this document using PAGEDUMB.PAG LASERDOC.BAT LaserJet Print this document using PAGE.PAG Program source (in C - it compiles straight away with Zortech C or Microsoft C, and should compile with no problems using any ANSI C compiler) is also supplied. Example usage PAGE -s PAGE page.doc Prints this document as a booklet. PAGE -s TINYFONT -c -b page.c Prints the page.c C source file on as little paper as possible How the PAGE.PAG configuration file works -t8 Tabs set to every 8th character. -p70 70 lines per page. -w181 181 columns across page. -B Print booklet. -f Include footers. -i9 Leave 9 chars indent for stapling. The indent is left each side of the centre, as we are printing a booklet. -H1 :H3. :H3. at the start of a line is treated as if there was a blank line above it. ________________________________________________________________________________ File page.doc Page 6 -H2 :H2. :H2. at the start of a line is treated as if there were two blank lines above it. -H3 :H1. ~[(s7B~[&dD ~[(s0B~[&d@ :H1. at the start of a line is treated as if there were three blank lines above it. Also the escape sequence Esc(s7BEsc&dD (sets bold and underline on for an HP Laserjet) is sent at the start of the line and Esc(s0BEsc&d@ (sets bold and underline off again) is sent at the end. -H4 :H0. ~[(s7B~[&dD ~[(s0B~[&d@ :H0. at the start of a line is treated as if there were four blank lines above it. Also the same escape sequence as for :H1. are sent. -T1 << < All the translation sequences defined here start with "<". In order to include literal copies of the translation sequences in this document, the first translation sequence translates "<<" into "<". Note the "1" after the "T". This tells PAGE that the output sequence ("<") takes up 1 character position on the page. -T ~[(s7B Occurrences of the character sequence "" will turn on bold print. Note that it is up to you to turn bold print off before the end of the line when printing multiple pages per sheet, otherwise the bold print may carry over to the adjacent page (if any). -T ~[(s0B turns bold off. -T ~[(s1S turns italics on. -T ~[(s0S turns italics off. -T ~[&dD turns underline on. -T ~[&d@ turns underline off. -T ~[(s0B~[(s0S~[&d@ Turns off everything - i.e. sets print to normal. ~[E~[&l1O~[(s16.66H~[(10U~[&l5C The last two lines in the file are the printer initialisation and termination sequences. This one Resets the printer, then sets it into landscape mode, and sets the font to "Line Printer Font". ~[E This line merely resets the printer. ________________________________________________________________________________ File page.doc Page 7 How the PAGEDUMB.PAG configuration file works This configuration file is for use with dumb printers. It is also used to produce the file PAGE.TXT. -t8 Tabs set every 8 characters. -w80 80 columns across the page. -f Include footers. -p60 60 lines per page. -F Use form feeds between pages. This is so that the file will print correctly no matter what size of paper is used (provided it has at least 60 lines per page). -u_ ;Underline with '_' Many dumb printers do not understand PC graphics characters (the default underline character used by PAGE). We use '_' instead. -H1 :H3. -H2 :H2. -H3 :H1. -H4 :H0. The heading leadin and leadout sequences are empty, so no escape sequences are sent. -T1 << < As before, "<<" is translated to "<". -T -T -T -T -T -T -T All the other translation strings are empty, so no escape sequences are sent. There are also no printer initialisation or termination sequences. ________________________________________________________________________________ File page.doc Page 8 Registration PAGE is supplied as shareware. The shareware version is complete and fully functional, but is supplied for evaluation only. Registration entitles you to use the program without restriction. Registration costs œ10 + VAT (currently œ1.75). U.S. users may register by sending a dollar check for $18. The registration fee should be sent to ... Trumphurst Ltd The Willows St. Martins Moor Oswestry Shropshire SY10 7BH England Tel : 0691-670318 Fax : 0691-670316 Email : page@trmphrst.demon.co.uk (internet) Visa and Master charge cards accepted (please supply card number, expiry date, and address). Revision history Changes in V1.11 * Fixed bug in header/footer file name printing which meant the correct file name was not always printed in booklet mode. * Added "Set left margin to column 4" command to landscape LaserJet .PAG files, to correctly centre output on the page. Changes in V1.10 * New network spooler switch (-N), causes printer to be reset, closed, reopened and re-initialised when the paper has to be turned over. If this option is NOT used, page does not close the printer until the end of the print job. * New append switch (-a) for file output causes output to be appended to the end of the file, rather than replacing any existing file. Changes in V1.9 * Printer is closed and reopened when the paper has to be turned over, so that networks and spoolers actually send the output to the printer. * PAGE now searches for any configuration and font files on the program directory if they are not found in the current directory. * Source amended to use stricmp for non-Zortech compilers, instead of strcmpl (which is the Zortech-only equivalent). * Thanks to Nick Leverton for suggesting these changes. ________________________________________________________________________________ File page.doc Page 9 Changes in V1.8 * Number of copies (-C) switch added. * -H switches numbered from 1 instead of 0. * Configuration files and documentation improved. * A blank page was sometimes incorrectly printed at the end of a document. Now fixed. Changes in V1.7 * Configurable underline character for headers/footers * Translation for bold/underline etc. introduced * Escape sequences can be written using '~' escape character * Heading level can be explicitly stated in document * Explicit headings can have associated escape sequences * Default file extensions of .PAG and .FON for configuration/font files * -F (use form feed between pages) switch added * Now omits completely empty lines at the top of any page. Changes in V1.6 * Usage message now takes 2 pages Changes in V1.5 * Booklet (-B) facility added. * Separate page numbering, switchable with -n added. * Sorting of command-line arguments (-S) added. * Progress messages as each page is printed. Changes in V1.4 * Now understands form feeds in the source document. Changes in V1.3 * Added RCS revision and date to usage display ________________________________________________________________________________ File page.doc Page 10 Changes in V1.2 * Source now kept in RCS with automatic configuration control. * Fixed bug which meant multi-column listings looped on last page if right-hand column wasn't full. Changes in V1.01 * Now allows user-defined fonts to be downloaded to printer. A font enabling about 5 pages worth of text to be printed on each A4 sheet is provided. * Now automatically caters for printing on both sides of the paper. * Option provided to indent the text to leave a left margin. Other programs available from Trumphurst REDIRECT DOS printer and device redirection. Capture printer or device (including stderr) output to disk. CUA compliant, mouse-driven, friendly user interface. DOS only. OBACKUP OS/2 backup and restore. Backs up to any OS/2 disk - floppy or removable hard disk. This fast backup program will operate in the background. It also compresses data as it is backed up, saving on backup media costs. ZED The programmers editor, as bundled with the original Zortech C compiler. This updated version includes full C source code. It is available for DOS, OS/2 and Unix. C++tmUIT Text mode user interface toolkit library for C++. Provides an easy-to-program, CUA compliant, user interface for C++ programmers. Works in DOS text mode. Full source code supplied. Unix version in the pipeline. CPPNEWS A Usenet news and mail reader for DOS. ________________________________________________________________________________ File page.doc Page 11