Last updated Jan 14 2003

Setting up the BSD Spooler to
print to Canon Networked Printers



Updated September 11 2000
I have received a fantastic document written by two people at Canon Italia.  It is a 31 page .pdf document that talks about printing from Linux using LPR/LPD.  It goes into wonderful detail on filtering.  They have obviously spent a lot of effort on it and it shows.  Great work guys!
PDF by Stefano Gelmetti & Franco Palleni
Download zipped PDF (0.5meg)

Updated Jan 14 2003
Stefano Gelmetti sent another great document about Linux using CUPS.  It is a training presentation targeted to beginners.
Used with the above pdf, it can be very helpful
Download the PDF (1.35meg)

The following document was stolen from various documents including RFC1179, 4.3 BSD Line Printer Spooler Manual, Linux Printing HOWTO, Man pages and other locations.  Printed without permission except for anything from Linux PHT (thanks Grant)

Tested with
Linux 2.2.13-7 lpr 0.38-3mdk(rpm) and
FreeBSD 3.3

Executive Summary

The very minimum needed in
/etc/printcap

lp:\
    :sd=/path_to_spool_dir:\
    :rm=ip address or name of printer:\
    :rp=name of queue:

example GP200e (with EFI Controller)

lp:\
    :sd=/var/spool/lpd/gp200e:\
    :rm=192.168.10.21:\
    :rp=print_200-216:


Detailed info

The distribution of Linux I tested was Mandrake 6.1 and it uses BSD printing using LPR/LPD from RFC1179.

LPD - Line Printer Daemon - spooling daemon - one runs to control everything on a machine and one is running per printer while it is printing.
LPR - Line Printer Request - lpr contacts lpd and injects a new print job into the spool.
LPQ - Line Printer Queue - lists the jobs in the queue.
LPC - Line Printer Control - lpd system control command.
LPRM - Line Printer ReMove - removes job from print spool.

LPD
To start daemon type lpd at prompt.
To check if lpd is running type ps -e |grep lpd

LPR
To print a file, at the prompt type lpr [options] [filename]
To print STDOUT command |lpr [options]

NOTE: lpr -f does not work on Canon equipment.  It filters out the escape codes.  You should use lpr -l   (See RFC1179 for more information)


LPQ
To get the status of a printer and its queue type lpq -Pprinter_name

LPC
lpc abort printer_name - terminates an active spooling daemon on the local host immediately and then disables printing.  It does not remove any jobs from the queue.
lpc stop printer_name - halts a spooling daemon after current job completes and disables printing.  Jobs can still be submitted to the queue.
lpc start printer_name - enables printing
lpc restart printer_name - restarts printer daemons
lpc disable/enable printer_name - allow spooling in the local queue to be turned off/on.  This will prevent/allow lpr from putting new jobs in the spool queue.  Although root can still use lpr, users can not.
lpc topq printer_name job#/user - place job at top of print queue.
lpc status printer_name - display status of daemons and queues on local machine.
lpc down printer_name [message] - turn the specified printer off, disable printing and put [message] in the printer status file.
lpc up printer_name - undoes the effects of down.
lpc clean printer_name - remove any temp, data, or control files that can not be printed from queue.

LPRM
lprm -Pprinter_name job# - removes job# from queue.  To get job# use the lpq command
 

/etc/printcap

The default printer is normally lp.  The environment variable PRINTER may be used to override this.  The printer name lp can only be used in one entry.

name:
Aliases are separated using a pipe.  The default printer with aliases would look like :

lp|canon|gp200e:\
lp:
lp is the device to print to.  Printers that reside on a remote host should have an empty lp entry.  In some cases you may have to point to /dev/null but you shouldn't use it unless the default doesn't work.
:lp=:\
sd:
sd means spool directory.  This is the path to the location where files are spooled before printing.  You should (probably) use a different directory for each printer.  The directories permissions should be set to 755, user=root, group=lp or daemon depending on your system.
:sd=/var/spool/lpd/canon:\
lf:
lf means log file.  Specifies the file that errors are to be logged to.  this file must exist or logging doesn't occur.
:lf=/var/log/canonerrs.log:\
rm:
rm means remote machine.  Points to remote host using IP address or host name.  If host name is used make sure you have an entry in /etc/hosts or in DNS.
:rm=192.168.10.21:\   or   :rm=gp200e:\
rp:
rp means remote printer.  Specifies the name of the printer on the remote host. For your queue name try here.
:rp=print_200-216:\
mx:
mx specifies the maximum allowable print size in blocks.  For unlimited use #0 (zero).
:mx#0:\
sh:
sh means suppress header.  Suppresses banner pager.  Doesn't seem to work with EFI devices.  Try 'lpr -h' Update 11/23/2000 - Check out the banner page
:sh:\
if:
if means input filter.  input filters are programs the print data goes through and could be modified by before it goes to the printer.
:if=/var/spool/lpd/canon/filter:\
: and :\
The slash after the colon at the end of each line means 'there is more information about this printer on the next line.'  The colon at the beginning of each line means 'more information about this printer starts here'  Do not start your entry with a colon and do not end your entry with a slash.

example entry in /etc/printcap

lp|canon|gp200e:\
:lp=:\
:sd=/var/spool/lpd/canon:\
:lf=/var/log/canonerrs.log:\
:rm=192.168.10.21:\
:rp=print_200-216:\
:mx#0:\
:sd:\
:if=/var/spool/lpd/canon/filter:
Filtering
I will probably do more on filtering later (don't hold your breath)  In the mean time here is a filter to fix the stair casing effect from Linux Printing HOWTO. (thanks to Grant Taylor <gtaylor+pht@picante.com>)

#!perl
# The above line should really have the whole path to perl
# This script must be executable: chmod 755 filter
while(<STDIN>){chop $_; print "$_\r\n";};
# You might also want to end with a form feed: print "\f";

I tested this on a gp200f and it worked great.  You don't need the form feed at the end for our products.



Back to UNIX                 Home

If you find an error or wish to comment please let me know