The ifhp Print Filter is the companion print filter supplied with LPRng and is normally installed together with the LPRng software. IFHP supports a wide variety of PostScript, PCL, text, and raster printers, and can be configured to support almost any type of printer with a stream based interface. It provides diagnostic and error information as well as accounting information. It recognizes a wide range of file types by using the file utility and the pattern matching technique demonstrated in the previous section, and can do selective conversions from one format to others.
The PostScript and PCL printer job languages are supported by most printer manufacturers. However, in order to have a job printed correctly the following steps must be taken.
The printer must be put into a known initial state by sending it the appropriate reset strings or performing a correct set of IO operations.
If accounting is being done, then the printer accounting information must be obtained and recorded. See Accounting for more information about LPRng support for accounting.
The file to be printed must be checked to see if it is compatible with the printer, and if not, a format conversion program invoked to convert it to the required format.
If the user selects a set of printer specific options such as landscape mode, duplex printing, multiple copies, or special paper, the appropriate commands must be sent to the printer to select these options.
The file must be transferred to the printer and the printer is monitored for any error conditions.
Any required end of job commands are sent to the printer, and the printer monitored for error conditions while the job finishes printing.
If accounting is being done, the printer accounting information such as page count and time used must be obtained and recorded. See Accounting for more information about LPRng support for accounting.
The ifhp filter uses the ifhp.conf database file to determine the actions and commands appropriate for various models of printers. See the ifhp documentation for details about the format and contents of this file. The default printer used by the ifhp filter is the HP LaserJet 4M Plus, which supports PostScript, PCL, and PJL. These defaults will also support a very wide variety of printers that support both PostScript and PCL.
Now we will use the ifhp filter. Find the path to the ifhp filter using the find command as we did in the previous exercise. Modify the printcap as shown below and use lpc lpd to restart lpd.
lp:sd=/var/spool/lpd/%P :force_localhost :lp=/tmp/lp # modify the path to ifhp appropriately :filter=/usr/local/libexec/filters/ifhp
Now reprint the file, and then display /tmp/lp using a text editor such as vi or emacs that shows control characters:
h4: {199} % cp /dev/null /tmp/lp h4: {200} % lpr /tmp/hi h4: {201} % vi /tmp/lp ^[%-12345X@PJL @PJL JOB NAME = "PID 405" DISPLAY = "papowell" @PJL RDYMSG DISPLAY = "papowell" @PJL USTATUSOFF @PJL USTATUS JOB = ON @PJL USTATUS DEVICE = ON @PJL USTATUS PAGE = ON @PJL USTATUS TIMED = 10 @PJL ENTER LANGUAGE = PCL ^]E^]&^]&k2G^]&s0C^]&l0O^]9^](s0P^](s10.00H^](s4099Thi ^]E^]%-12345X@PJL @PJL RDYMSG DISPLAY = "papowell" @PJL EOJ NAME = "PID 405" @PJL USTATUSOFF @PJL USTATUS JOB = ON @PJL USTATUS DEVICE = ON @PJL USTATUS PAGE = ON @PJL USTATUS TIMED = 10 @PJL RDYMSG DISPLAY = "" ^[%-12345X
The output now contains all of the control sequences and setup codes needed to print a text file on the printer. For details on the exact meaning of each of these entries, see the PCL and PJL documentation.