HP Laserjet printcap and filter instructions By David Efflandt - efflandt@xnet.com - 1/2/97 This was something I did before I got around to trying magicfilters. It will at least get you up and running for print text, postscript and dvi files. While this is specific to my HP Laserjet 4L and above, it will help you work with older Laserjets, printers that emulate them and other printers. First make sure you have compiled the kernel with parallel printer support. I have it as an autoloading module using kerneld. If you can do 'lpr filename' and get something to print (even if it doesn't look right) that is a start. I think current Linux distributions install all the gs drivers when you install ghostscript now. For older distributions you may need to select which drivers to install. To find out what drivers are installed just type 'gs -?' (without quotes) in the shell. I am using Slackware96. To see what dvi laserjet drivers you have type 'man dvilj'. Note that these are 'if:' (preferred method) rather than 'of:' filters. An input filter (if:) runs for each file, whereas, an output filter (of:) runs once for a group of files and spits out an extra page. NOTE: For consistancy I call these 'if:' filters hpjlp, hpjps and hpjdvi. If someone has a different hp printer model, all they have to change is the printer device in the /var/spool/lp1/scriptname. If you are not up on vi or emacs yet, a simple to use UNIX (Linux) editor is pico. To edit a file simply type 'pico filename'. Edit /etc/printcap to comment out (#) the generic printer then modify the lp|hpj listing to the following (leading spacing is just a [tab] for readability) with added gs and dvi entries. An easy to use UNIX (Linux) text editor is 'pico', but if any long lines wordwrap make sure you either backslash (\) the end of the broken line or backspace it back onto one line in scripts. Check the filter paths in your existing printcap to see if they begin /var/spool or /usr/spool and modify the lines below to match: NOTE: Any "l" below is likely a small L, except lp1 is small LP1. Save your existing /etc/printcap (cp printcap printcap.orig) and edit printcap to revise/add these lines: # HP Laser Jet lp|hpj:\ :lp=/dev/lp1:\ :sd=/var/spool/lp1:\ :mx#0:\ :if=/var/spool/lp1/hpjlp:\ :lf=/var/spool/lp1/hp-log:sh # ps|hpjps:\ :lp=/dev/lp1:\ :sd=/varr/spool/lp1:\ :mx#0:\ :if=/var/spool/lp1/hpjps:\ :lf=/var/spool/lp1/hp-log:sh # dvi|hpjdvi:\ :lp=/dev/lp1:\ :sd=/usr/spool/lp1:\ :mx#0:\ :if=/var/spool/lp1/hpjdvi:\ :lf=/var/spool/lp1/hp-log:sh # end of modification The following are scripts that you create in /var/spool/lp1. In /var/spool/lp1 call the following script 'hpjlp' (use 'pico hpjlp' to compose it if unfamiliar with vi or emacs). This should work for any laserjet and many other printers. Make sure '#!/bin/sh' is on the first line of the script: #!/bin/sh # if: filter for HP to switch LF to CR,LF # The "echo -ne" assumes that /bin/sh is really bash echo -ne \\033\&k2G cat echo -ne \\f echo -ne \\033\&k0G # end of hpjlp NOTE: My HP 4L is really smoothed 300 dpi with extra fonts over the HP 3. These will work with other HP 4 and 5 models, but can be edited to use HP 4 drivers if you want true 600 dpi for those models. In the same directory create 'hpjps' (or any name that matches the ps if: entry in /etc/printcap) with the following. For HP 4, 4M, 5L or other 5's use -sDEVICE=ljet4 (for HP 4L use -sDEVICE=ljet3): #!/bin/sh # if: filter for .ps on HP laserjet w/o postscript # Adjust -sDEVICE to your printer type # 'gs -?' will show available sDEVICE drivers /usr/bin/gs -q -dSAFER -dNOPAUSE -sDEVICE=ljet3 -sOutputFile=- - # end of hpjps In the same directory create 'hpjdvi' (or any name that matches the dvi if: entry in /etc/printcap) with the following. Use dvilj4 for HP 4, 4M, 5L or other 5 models (below shows dvilj4l for my 4L): #!/bin/sh # if: filter for .dvi on HP laserjet, see 'man dvilj' # Adjust dvi converter filename below to your lj printer type cat >/tmp/$$.dvi /usr/bin/dvilj4l -e- /tmp/$$.dvi rm /tmp/$$.dvi # end of hpjdvi Then (as root) from the shell in /var/spool/lp1 type the following: touch hp-log chown root:lp hp* chmod 755 hpj* chmod 664 hp-log Reboot ('shutdown -r now'). Then 'lpr filename.txt' will print plain text, 'lpr -Pps filename.ps' will print postscript and 'lpr -Pdvi filename.dvi' will print dvi. Tex files (not plain text) have to be converted to dvi for printing (I have not figured out a filter to print tex files directly yet).