Computer Music Politics Miscellany

Information on LPR Printing

Basic printing service setup is beyond the scope of this document. The printing howto's do a good job of explaining the lpr printing system. This document is designed to provide additional information about some of the more mundane requirements a person might have. Like:

Reviving an old Dot Matrix printer

Resources:

Printing ASCII text to a dot matrix printer

Printing to a character based printer is a simple task; however, some people may have little knowledge of these ancient beasts. After inheriting a couple of boxes of form feed paper and recovering my 16 year old FX-80 from the closet I configured an old DEC Multia as a print server for the Epson. It is great for printing huge README files, HOWTO files, etc.. The paper is cheap; the printer ribbon is cheap; the time is cheap; and the Multia and Epson could care less about the hours of cranking out documentation. In character mode these old printers are reasonably fast—fast enough to do source code listings and draft quality printouts of your latest article. Unfortunately, they are extremely slow in graphics mode.

  1. /etc/printcap

    The following is a fairly typical entry in /etc/printcap for an Epson FX-80 printing ASCII text:

        text|fx80text:\
            :lp=/dev/lp0:\
            :sd=/var/spool/lpd/fx80:\
            :lf=/var/spool/lpd/fx80/errs:\
            :if=/var/spool/lpd/fx80/FX80Filter:\
            :mx#0:\
            :sh:\
  2. Spool directory and filter

    Create the spool directory /var/spool/lpd/fx80 and put the filter named FX80Filter(see below) in it. The line in /etc/printcap beginning ":if=" tells lpd where the input filter is located.

    A very simple filter that does nothing but forward the text to the printer would look like this:

        #!/bin/sh
        cat

    Filters to send ASCII text to a dot matrix printer can take advantage of some of the printer's built-in features: choice of fonts, emphasized mode, skip-over-perforations, etc.. The following filter demonstrates some basic controls for an Epson FX-80 printer.

        #!/bin/bash
        RESET=\\033@
        ELITE=\\033M
        LEFTMARGIN=\\033l\\007
        SOP=\\033N\\006
        FF=\\014
        echo -ne $RESET$ELITE$LEFTMARGIN$SOP
        cat
        echo -ne $FF

    The first line explicitely calls bash instead of sh because "echo -ne" is specific to bash. Escaped octal is used because hex does not seem to work when sent to the printer; however, hex works when sent to the console. The filter will reset the printer, change it to elite mode, set a left margin (for punching holes to install paper into a ring binder), and skip-over-perforations, then print text sent from lpr, and, finally, form-feed the last page. Setting the font to elite allows a total of 96 characters to be printed on one line. In this example the left margin is 6 so you can still print a line of 90 characters.

    Instead of using a filter to format the text for the printer you can use pr. The filter can then be simplified. The example below uses the filter to set the printer to elite mode and leaves it up to pr to set a left margin or other niceties.

        #!/bin/bash
        RESET=\\033@
        ELITE=\\033M
        FF=\\014
        echo -ne $RESET$ELITE
        cat
        echo -ne $FF
  3. Printing ASCII to printer
    • Text file to printer:

      lpr -Ptext any-ascii-text.txt

    • Troff to ASCII to printer:

      groff -Tascii finename.tr | lpr

    • Man pages to ASCII to printer (man pages are pre-formatted troff):

      man man | col -b | lpr

    • Using pr to format ASCII text to printer:

      pr filename.txt | lpr

Last updated: Saturday, 13-Sep-2014 01:47:40 UTC