Simple printing

Author: John M. Gabriele
Date: May 2007
Back to:homepage

Contents


To simply print to a PostScript printer that has its own ethernet port and is plugged into your LAN, you don't need LPRng nor CUPS. Just do the following:

  1. Shut down printing: /etc/init.d/lpd stop

  2. Edit your /etc/printcap to contain only:

    lp|remote network printer:\
        :rm=192.168.1.5:\
        :sd=/var/spool/lpd/lp:\
        :lf=/var/log/lp-errs:\
        :mx#0:\
        :sh:
    

    replacing 192.168.1.5 with whatever the IP address of your printer is.

  3. Restart printing: /etc/init.d/lpd start

To view your current queue of print jobs: lpq

To remove jobs from the print queue: lprm <job_number>

To print a document, lpr <filename> will sometimes work for simple text files, but it's probably preferable to just use a2ps.

Using a2ps

Most often I'm just printing out text files. Here's some example commands to do just that:

a2ps filename.txt
a2ps --columns=1 --portrait --font-size=8 --tabsize=4 --pretty-print=sh -g filename.txt

That command automatically sends the postscript directly to the default printer. Lines will be automatically wrapped for you. Note, -g is shorthand for --highlight-level=heavy. Also, it seems that you don't always have to use that --pretty-print=foo option, as a2ps guesses (for me anyway) which style to use.

That said, here's some other file types you can specify besides shell scripts ("sh"):

c
gnuc
cxx -- C++
make
gmake
html
java
perl
python

Other options to consider:

--output=filename.ps
--printer=display        # To view it on-screen with gv instead of printing.
--highlight-level=none   # or heavy (default is "normal").
--landscape
--line-numbers=5         # Print a line number every 5 lines.
--no-header              # To save some space on the page.

Printing out a pdf

Just make sure you have the psutils package installed, then run a2ps foo.pdf

Viewing

Recall, you can always save the .ps file (--output=filename.ps) and view it using the gv command.