Michael W. Lucas
Printing on a UNIX-like operating system has traditionally given headaches to even experienced sysadmins. The FreeBSD Handbook has a big section on how printers work, and it's well worth reading if you want to become intimate with the innards of printing. Personally, I don't want to struggle with identifying file types, input filters, and output filters; I want to plug in a printer and have the Magical Printer Pixies do all the work for me.
That's almost possible with Apsfilter. Apsfilter handles all of the ugly details of printer setup for you, making printer setup almost painless. With a couple of moments of preparation, you can make almost any printer work reliably. While this article is written from a FreeBSD perspective, Apsfilter works nicely on other BSD, Linux, and even commercial BSD-like operating systems such as Solaris (with the occasional tweak).
If you have a PostScript printer, Apsfilter can speak PostScript directly to
it. I'm not that lucky; my printers are consumer models that expect custom
drivers. Apsfilter uses Ghostscript to actually talk to these printers. The
FreeBSD ports collection includes two versions of Ghostscript:
Pick either one. As a general rule of thumb, the AFPL Ghostscript is slightly
more up-to-date than the GNU one. While AFPL Ghostscript version comes with
licensing restrictions that make it problematic to resell, it is perfectly
suitable for home or office use. If licensing purity is important to you, use
the GNU version. You might already have a version of Ghostscript installed on
your system, as many other programs require it as a dependency. Choosing what
you already have installed is always a good place to start.
Then identify the Ghostscript driver for your printer. As printer drivers are usable across any UNIX-like OS, the LinuxPrinting.org database is quite useful for this. I also find that typing the printer model and the words "Ghostscript driver" into Google gives me excellent insight into how well the various drivers work and which driver I should try first.
Many popular inkjet printers have "best" available drivers in the
gimp-print port (
of in Ghostscript itself. If your printer uses one of these drivers, you'll
want to install
gimp-print. Specify the
WITHOUT_CUPS=yes environment variable when building
gimp-print; we'll use standard
lpd(8) in this article
and to avoid the clutter of CUPS.
Finally, note what sort of interface your printer uses: parallel or USB? While parallel printers are hard to find on store shelves these days, quite a few of us have older parallel printers that are still quite serviceable.
Armed with this information, proceed to the installation of Apsfilter. Apsfilter
includes a variety of filters to enable it to print a wide variety of
documents. Like many people, I don't care what format a document is in. When I
hit Print, I just want whatever I'm looking at to appear on paper. By
default, Apsfilter gives you the option to choose which sorts of files it can
handle. Similarly, the Ghostscript port install scripts present options to
install all sorts of different drivers. These are nice, if you're concerned
about minimizing your install size or if you have a dedicated-purpose machine.
For an average print server or small machine, however, I find it simplest to
install absolutely everything available. This takes a while to run, but time
for the computer to compile is far more plentiful than time for me to determine
which features I will need in the future. By setting the variables
building the Apsfilter port, you can tell Apsfilter and Ghostscript to compile
in every possible feature.
FreeBSD's Apsfilter port defaults to using GNU Ghostscript. If this is your
choice, the standard
make install will do everything you need. If
you choose AFPL Ghostscript, however, tell the Apsfilter port about it with the
So, installing absolutely everything, using AFPL Ghostscript, is as simple as:
# cd /usr/ports/print/apsfilter # make WITH_GHOSTSCRIPT_AFPL=yes BATCH=yes APSFILTER_ALL=yes install clean
This is a good time to go do something else while your computer downloads and compiles a whole heap of source code.
Just to make this a little more fun, I have two printers on my home system. One printer is a Brother HL-1240 laser printer with both USB and parallel connections. The other is an old Canon BJC-250 inkjet with only a parallel connector. As I only have one parallel port, I'll use the laser printer's USB interface and dedicate the parallel port to the color inkjet.
Google tells me that my Brother HL-1240 laser printer is supported by the
ljet4 driver and by a HL1240-specific driver. People
report varying success with each, and the LinuxPrinting.org database recommends
that I use the HL1240-specific driver. Similarly, my BJC-250 is supported by
bjc50 and the
gimp-print-ijs drivers. (While the
BJC-50 looks like a different printer than the BJC-250, they're apparently
quite similar inside. This is not uncommon.)
Once Apsfilter is installed and you have the necessary information about your printers, run the Apsfilter setup program.
# cd /usr/local/share/apsfilter # ./SETUP
I first chose to use AFPL Ghostscript version 8, and I get a rather amusing error at first.
Found ghostscript version 8.00 ... You have to upgrade at least to gs version 6.50! But you should upgrade to gs 7.00 for full driver support prior installing printers with SETUP. Do you want to continue? [Y/n]
A quick glance at the code shows the very simple but harmless problem. I've already notified the Apsfilter people about this, and hopefully it will be corrected before you read this article. Ignore this warning if you see it and have a newer Ghostscript installed.
While Apsfilter is available under the GPL, the author also collects postcards. Apsfilter will ask you to request his snail-mail address so you can send him one in gratitude for setting up your printer. Sending someone a postcard is much faster and simpler than figuring out how to work out printing on your own, and I encourage you to indulge him. The setup script also provides a few screens of caveats and warnings, and you should at least be aware of them before continuing. It then makes one final check:
Your line printer scheduler's spooldir seems to be: /var/spool/lpd drwxr-xr-x 3 root daemon 512 Sep 2 19:12 /var/spool/lpd The Owner of your spooldir seems to be: root The Group of your spooldir seems to be: daemon Is this correct? [y/n]
If this isn't correct, it probably means that you've installed some other printing software or someone has been doing unnatural things to your system. Fix it before continuing.
If you've previously run Apsfilter's setup script, Apsfilter will ask if you want to add another printer or overwrite the existing entries in /etc/printcap. If you don't have any working printers yet, go ahead and overwrite the existing entries. If you have a working printer and are adding a second, tell it to add another entry. As printer setup is rather tedious, I usually track working printer configurations via RCS.
After all of these preliminaries, you'll reach the main Apsfilter menu.
================================================================== A P S F I L T E R S E T U P -- MAIN MENU -- ================================================================== (D) Available Device Drivers in your gs binary (R) Read Ghostscript driver documentation (devices.txt) (1) Printer Driver Selection  (2) Interface Setup  (3) Paper Format  (4) Printing Quality [medium] (5) Color Mode [full] (6) Print Resolution in "dots per inch" [300x300] (7) Default Printing Method [auto] (A) Abort installation (don't do anything) (Q) ==> Finish installation Your choice?
The most important steps are numbers 1, 2, and 3. Once you know your printer works at all, you can back up your working /etc/printcap and re-run the setup script to adjust other settings. If you're interested in the Ghostscript drivers, it's much simpler to read about them online at the Ghostscript web site. Start by selecting your printer driver, option 1. I'll set up the laser printer first.
The printer driver option will bring up a menu of choices, most of which are irrelevant for most users. If you have an actual PostScript printer, select PostScript. Some manufacturers have provided UNIX drivers for their printers, and those are also options. Those of us with commodity printers almost certainly want to choose the "printer driver natively supported by Ghostscript" option.
AFPL Ghostscript turns out to include the HP Laser Jet 4 driver
ljet4, but not the
hl1240 driver. As this is
"Printing for the Impatient," I just tried the HP Laser Jet 4 driver. After choosing a driver,
Apsfilter returns to the main menu.
When choosing an interface, Apsfilter gives options to talk to Novell printer servers, Microsoft print servers, and other network operating systems. We'll look at sending print jobs to a remote Windows print server via TCP/IP printing in a future article. For a locally connected parallel or USB printer, choose the "local parallel/USB" option.
You then need to enter the device name. On any BSD, you have three options.
/dev/lpt0 is the first parallel printer port on the system.
Computers these days have at most one parallel port; if you have more than one,
you'll need to identify to which one your printer is attached.
/dev/ulpt0 is the first USB printer attached to the system. While
this works for most USB printers, some printers misbehave when addressed via
/dev/ulpt0. For example, my Brother laser printer resets itself
and does not print whenever I send a print job via
your printer has this problem, use the
After selecting the device, Apsfilter will return to the main menu so that you can choose a paper format. Be certain to enter the proper size paper for your printer!
Finally, test your setup. Enter
T at the main menu, then go
through the various
OK prompts until you finally see a message
Printing test page... -rw-r--r-- 1 root wheel 224354 Sep 19 20:36 /tmp/apsfilter30802/test_page.aps
At this point, your printer should start producing a test page with a bunch of different sized fonts, a detailed drawing of a tiger, and a photograph of the author. If you get this you have successfully given Apsfilter everything it needs to talk to your printer, and you can continue. If not, then go back and try some different settings or research your printer's requirements further. If you printer has multiple drivers, you can print a test page under each and see which produced better output on your particular system.
When you're ready to have Apsfilter set up the printer once and for all,
I from the main Apsfilter menu. Apsfilter will prompt you
for a name for the printer. The standard for UNIX-like operating systems is to
call the main printer
lp, and many programs use that as their
Once you name your printer, Apsfilter will automatically set up /etc/printcap with the proper filters.
Now that you have your first working printer configuration in /etc/printcap, back it up! All of this work has generated a measly eight lines of configuration information, but you don't want to go through it all again.
Adding a second printer is just as easy. When starting Apsfilter a second
time, be certain to tell Apsfilter that you wish to add a new printer, not
overwrite your existing entries. In this case, the BJC-250 is supposedly best
supported by a
gimp-print print driver, so select that option from
the driver selection menu. Other than this minor change, the rest of the setup
process is absolutely identical. Also be sure that you give this printer a
unique name. While Apsfilter will suggest a name, feel free to come up with
lpd(8), the line printer spooler daemon. Ensure
lpd starts automatically at boot by making the appropriate
entry in /etc/rc.conf.
Apsfilter includes a wide variety of additional features, including the ability to do duplex printing on printers that support it and the ability to fake duplex printing on printers that don't, as well as nifty tricks like printing to a file instead of the printer. We'll look at those in a future article. Next time, we'll fine-tune printer setup and configure a client to print from this machine.
Read more Big Scary Daemons columns.
Return to the BSD DevCenter.
problem in printing using apsfilter
2007-07-18 05:21:00 gpraveenya [View]
Printing sucess at last
2004-10-31 04:34:48 MrBluez [View]
Printing sucess at last
2004-10-31 04:33:50 MrBluez [View]
2004-04-27 08:17:14 joepekoe [View]
hahaha the irony of this article is just rich
2003-11-20 09:49:42 anonymous2 [View]
RE: hahaha the irony of this article is just rich
2004-01-02 10:19:42 anonymous2 [View]
2003-11-11 12:43:07 anonymous2 [View]
2003-11-11 04:25:36 agshekeloh [View]
2003-11-10 20:14:15 anonymous2 [View]
2003-11-10 13:49:39 anonymous2 [View]