Setting up a printer

Setting up a printer

Roy Miller wrote in with his notes
about setting up a printer.  As always, such articles are always welcome.  It’s
easy to get published.  Just sent it in.  Even if you’ve never written anything
before, give it a try.

Thanks Roy.

The install

Installing a printer is rather easy for people without postscript printers.  The
program apsfilter sets up your printcap so anything that goes through is
converted from postscript to whatever format your ‘windows’ printer uses.

First you
must install apsfilter, I’m assuming you know how to do this.  I installed
from a package so things might be a little different if you use ports.

I’m also assuming you already have the printer device in your kernel and that /dev/lpt0
works.  See Building
and Installing a Custom Kernel
in the FreeBSD
Handbook
for more information on modifying your kernel.

Remember, I have the entire ports tree.  So it was
easy.  See also, Installing a port without installing
the ports
.  To install apsfilter from the ports, do this:

cd /usr/ports/print/apsfilter
make install    

After the install, go to /usr/local/apsfilter [in recent versions
of apsfilter, go to /usr/local/share/apsfilter] and run SETUP.

# su
Password: (if you are not running as root)
# cd /usr/local/apsfilter
# ./SETUP    

You will see a bunch of license junk, just nod and say Y.  When you finally enter
the config screen, you should see this:

=============================================================
A P S F I L T E R S E T U P -- MAIN MENUE --
=============================================================
currently selected
-------------------------------------------------------------
(D) Available Device Drivers in your gs binary (gs -h)
(R) Ghostscript 5.50 docu about printer drivers (devices.txt)
(1) Printer Driver Selection [ ]
(2) Interface Setup []

For printing the test page:
(3) Print Resolution in "dots per inch" []
(4) Toggle Monochrom/Color (1bpp=b&w) []
(5) Paper Format []
(T) Print Test Page (after step 1-5)
(V) View perf.log (times of print attempts)

(C) ==> Continue printer setup with values shown above

(Q) Quit Setup

Your choice ?

First you should hit ‘R’ to make sure your printer is supported.  If not, I doubt
if you’ll find any driver for your printer.

Next, hit ‘1’ to select your printer.  A menu will pop up with a list of choices.
  I suggest that you look under the Uniprint section (number 8 then ‘B’) first.

When you have selected your printer you should tell apsfilter what device file you use,
‘2’ on the main menu.  It tells you what the default device files are, and the MSDOS
equivalents. The choice is yours.

If you would like to print a test page, skip 3 and 4, they are automatic.  Under 5
choose the paper size of your location, the US is ‘letter’.  Then hit ‘T’.

If everything looks good (note: the colors may be distorted on some printers) hit ‘C’.

It will prompt you on what kind of printer, color or monochrome.  Then it will
check the permissions on the printer spool.  You should see something like this:

drwxrwxrwx 7 root daemon 512 Apr 1 13:34 /var/spool/lpd    

If the first thing you see is drwx-r-xr-x then you need to change it so
users can write to it.  If you only want certain users to write to it, you should
already know how to set the proper permissions.

After that you’ll see some notes on apsfiler and usage, read it if you like.  When
it’s done, set the permissions to /var/spool/lpd by doing this:

# chmod a+rw /var/spool/lpd
# chmod a+rw /var/spool/lpd/*
# chmod a+rw /var/spool/lpd/*/* 

This will let all the users write to the spool directory, to each printer’s directory,
and to the lock files.

Then you need to have lpd load on boot.  lpd is the printer
daemon that sits around, waiting for somebody to print, then it puts it on the queue so
every prints, but one at a time.  Create a file in /usr/local/etc/rc.d/
that looks something like this:

#!/bin/sh
[ -x /usr/sbin/lpd] && /usr/sbin/lpd && echo -n " lpd"

Perhaps you could call this file lpd.sh.  This file does the following:

  1. tests for the existance of the executable
  2. starts the executable
  3. prints to the screen

For more information on this, please see Starting stuff at boot
time

Now your printer should work.

Postscript printing

To print a postscript file just type:

lpr file.ps.

Most word processors already know how to print with lpr, so they should work already.
  The next step is sharing your printer with Windows computers.

Printing from Windows

I’m assuming you already have Samba installed under FreeBSD
and it works.

Next you need to edit your /usr/local/etc/smb.conf file.
  Make sure these lines are in there:

...
[myprinter]
comment = this is my printer, please flood it with junk
path = /var/spool/lpd/samba
printer = raw
public = yes
writeable = no
printable = yes
... 

Then you have to create the directory /var/spool/lpd/samba, and set the
permissions so that the samba guest user can access it.

On the windows machine you have to install the printer.  Open up the printer
folder (start | settings | printers) and double-click on "add printer".  
Hit ‘next’, ‘network printer’/’next’, in the text box type "\\{freebsd server name or
IP}\myprinter"/’next’, find your printer in the list.  If your printer is not in
the device list, break out your driver disk and hit ‘have disk…’.  Slap on a
windows printer name, set it as default if you like, print a test page, and everything
should work.

A note about colors

If colors are distorted when printing under FreeBSD, they will NOT be distorted when
printing from Windows, since Windows is using real drivers to print.

and that’s it

And that’s it…if it doesn’t work for you, you have my sympathies, and go to #freebsd
on undernet.org for some help.

[ed. note: if it doesn’t work, and you find out why,
please drop Roy Miller or add a comment about what
else you did.  cheers]

2 thoughts on “Setting up a printer”

  1. apsfilter is great for printing TO Windows printers as well. This article doesn’t talk about it but it is so easy when you run /usr/local/share/apsfilter/SETUP after installing it from the port.

    1. Brian K. White

      I followed the article to the letter and still cannot get anything to come out of my printer.

      Printer works fine for plain lpr commands and other apps like galeon.

      Samba works fine in that from a windows2000 machine I can browse/read/write files on freebsd.

      the printer shows up in network neighborhood.

      I "connect" to the printer share and install the driver without error (HP LaserJet 5L, which is what the printer actually is)

      I don’t get any connection or permissions errors trying to print a test page, and the print job dissappears from windows immediately.

      but the printer doesn’t actually do anything. not even any data light activity.

      a valid PJL/PCL file does appear in the defined spool directory for a split second. (I captured one by starting a "while true ;do cp * /tmp ;done" before hitting the print test page button.

      catting the captured temp file to /dev/lpt0 _does_ work.

      freebsd 4.7-stable
      samba 3.0alpha20

Leave a Comment

Scroll to Top