-->
Page 236
The pr command has 19 different command-line options to help you format documents for printing. For example,
# pr +9 -h CONFIDENTIAL DOCUMENT -o 5 < myfile.txt | lpr
will print your document, starting at page 9, with a header containing the date, time, words "CONFIDENTIAL DOCUMENT," and page number, with a left margin of 5 spaces.
Another text formatter you might want to try is the fmt command; see its man page for details.
Printer filters work by defining and inserting printer definitions into your /etc/printcap file. Embedded in each printer description is a pointer (pathname) to a script or program containing the filter that is run before output to the printer. See the printcap man page and the sample /etc/printcap listing later in this chapter.
Even if, as a Red Hat user, you're spoiled with the printtool program, there might be times when you need to use other programs or scripts to help set up or manage printing. If you can't or don't want to run X, but want to easily install printing services for HP or PostScript printers, one great solution is the printing filter package called APSfilter, by Andreas Klemm and Thomas Bueschgens. Installing APSfilter is a snap, and it's even easier to use.
APSfilter works well with all Linux printing applications. Two added benefits are that it prints two formatted pages in Landscape mode on a single page when you print text documents, saving you paper, and automagically recognizes the following documents: xfig, pbm, pnm, tiff, jpeg, gif, Sun rasterfile, PostScript, dvi, raw ASCII, gzip, and compressed.
One downside is that APSfilter's printing of grayscale is not as good as the grayscale printing offered by the printtool program's setup (at least on HP deskjets). Hopefully, this will be fixed in the next version.
If you have a Canon Bubble Jet, IBM Proprinter X24E, Epson LQ1550, or Epson Stylus, Olav Wolfelschneider's BubbleTools printer drivers can help you. This filter program converts a number of graphics formats, including Group 3 Fax, for this series of 360-dpi printers.
Another printer filter similar to APSfilter is H. Peter Anvin's magicfilter, which detects and converts documents for printing through a combination of a compiled C filter and printer configuration file.
You can find APSfilter, BubbleTools, and magicfilter, along with other Linux printing utilities at sunsite.unc.edu/pub/Linux/system/Printing.
Page 237
If you want a print spooler specifically designed for PostScript printers, give Dave Chappell's PPR a try. PPR works with printers attached to parallel, serial, and AppleTalk (LocalTalk) ports, along with other network interfaces. PPR also works much like other non-PostScript printer filters, and converts different graphics file formats for printing.
You can find PPR at ftp://ppr-dist.trincoll.edu/pub/ppr/.
The future of Linux printing has arrived, and its name is LPRng. This print spooler software, descended from the 4.3BSD release, but totally rewritten from the ground up, offers a host of benefits and features in the areas of distribution, setup, use, and security. Some of these are as follows:
You will find the latest copy of LPRng at the site ftp://dickory.sdsu.edu/pub/LPRng (along with other neat printing utilities).
Want to know how much printing you or your users have been doing and at what cost? Should your printer's name be "TreeEater"? See the man pages for the pac command, which you can use to track usage and costs. You'll also need to read the man pages for the printcap database to see how to enable printer use accounting.
The following are some helpful tips to help you print documents or set up applications for easier printing.
Want to print directly from emacs? You can print the entire buffer, unformatted or formatted, by pressing Esc+X, typing lpr-buffer, and hitting Enter, or by pressing Esc+X, typing print-buffer, and hitting Enter. Just make sure that you set your lpr-switches variable in your .emacs file to point to the correct printer in your /etc/printcap file.
Page 238
You'll find emacs, along with its help files and documentation, on your Red Hat Linux
CD-ROM.
Applixware, a fully integrated suite of office tools and development environment, is a newcomer to the Linux scene, but is a veteran UNIX application. If you want to create, import, edit, and print documents with ease, this product is a good bet.
However, here's a tip on how to set up your printer for Applixware you won't find in the program's manuals. Go to Applixware Preferences and select Printing. In the Printing Preferences dialog that comes up, set Default Printer Type to PostScript, as shown in Figure 12.3. Then scroll down the list of preferences at the bottom of the dialog to Pathname of Your Printer Aliases File. Click in the Value text area, and enter the path of the file (/etc/printers). Then create a simple ASCII file containing a list of printers defined in your /etc printcap file. (You are using X so that you can do a lot of different things at once, aren't you?)
For example, here's a sample /etc/printcap for an HP DeskJet 500, created following installation and setup using printtool. Note that printtool offers four different modes for the printer (normal black-and-white printing, normal color printing with color cartridge, Floyd-Steinberg black-and-white print for better grayscale, and Floyd-Steinberg color printing for best, but slow):
### /etc/printcap ### ### Please don't edit this file directly unless you know what you are doing! ### Be warned that the control-panel printtool requires a very strict format! ### Look at the printcap(5) man page for more info. ### ### This file can be edited with the printtool in the control-panel. ## ##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 8 1 DJ500greyscale:\ :sd=/var/spool/lpd/lp0:\ :mx#0:\
Page 239
:sh:\ :lp=/dev/lp1:\ :if=/var/spool/lpd/lp0/filter: ##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 24 {} DJ500colorbest:\ :sd=/var/spool/lpd/lp0:\ :mx#0:\ :sh:\ :lp=/dev/lp1:\ :if=/var/spool/lpd/lp0/filter: ##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 3 {} DJ500colornormal:\ :sd=/var/spool/lpd/lp0:\ :mx#0:\ :sh:\ :lp=/dev/lp1:\ :if=/var/spool/lpd/lp0/filter: ##PRINTTOOL3## LOCAL cdj500 300x300 letter {} DeskJet500 1 1 DJ500mononormal:\ :sd=/var/spool/lpd/lp0:\ :mx#0:\ :sh:\ :lp=/dev/lp1:\ :if=/var/spool/lpd/lp0/filter:
From this listing, create and save the file /etc/printers with the following four lines:
DJ500greyscale DJ500colorbest DJ500colornormal DJ500mononormal
Then, under Applixware, save the preferences by clicking the OK button and then the Dismiss button.
Now, when you go to print from, say, Applix Words, you'll see these four printers listed in your Print dialog box. Select an appropriate printer, make sure that PostScript is selected in the Class pop-up menu, and uncheck the Print to File box. When you hit OK, your file will immediately print using the fonts and formatting of your Applix Words document.
The following are short descriptions of just a couple of the programs offering handy printing services available either in your Red Hat distribution or for Linux. You'll find some of these indispensable.
One great tool that does a lot more than just print graphics is John Bradley's program, xv, which runs under X. It can read and export nearly 18 different graphics file formats, and even comes in a scanner-driver version so you can scan and immediately print. You can print a quick copy of a graphic with the click of a button.