When printing to vintage hard copy devices or to printers that support a text mode, many UNIX users discover that their output suffers from a case of the jaggies.
Input file: This is a nice day Output: This is a nice day
UNIX systems terminate lines with a single NL (new line) character. This causes the printer to move down one line on the printing page but does not change its horizontal position and print the next character at the left margin. This is done by using the CR (carriage return) character. You need to convert the single NL to a CR-LF combination and the lpf filter supplied with LPRng does this.
First, locate the lpf filter. You can find it by using the command:
h9: {160} % find /usr/ -type f -name lpf -print /usr/libexec/lpr/lpf
We will first see what the output is like without lpf, and then see what it does. Modify the lp printcap entry as shown below and then use lpc restart to restart the lpd server.
lp:sd=/var/spool/lpd/%P :force_localhost :lp=/tmp/lp
Print a file and view the output using the following commands. If you do not have the od (octal dump) program, try using hexdump or some other appropriate program that displays the numerical contents of the file.
h4: {189} % cp /dev/null /tmp/lp h4: {190} % lpr /tmp/hi h4: {191} % od -bc /tmp/lp 0000000 150 151 012 h i \n 0000003
Now we will use the lpf filter. Modify the printcap as shown below and use lpc reread to cause lpd to reread the configuration information.
lp:sd=/var/spool/lpd/%P :force_localhost :lp=/tmp/lp # modify the path to lpf appropriately :filter=/usr/local/libexec/filters/lpf
Now reprint the file:
h4: {192} % cp /dev/null /tmp/lp h4: {193} % lpr /tmp/hi h4: {194} % od -bc /tmp/lp od -bc /tmp/lp 0000000 150 151 015 012 h i \r \n 0000004
As you see, lpf changes the LF to a CR-LF sequence.