Printing for the Impatient
by Michael W. Lucas11/06/2003
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:
print/ghostscript-gnu and print/ghostscript-afpl.
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 (/usr/ports/print/gimp-print) instead
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
APSFILTER_ALL and BATCH to YES when
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
WITH_GHOSTSCRIPT_AFPL variable.
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
Ghostscript 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
the 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.
|
Related Reading
The Complete FreeBSD |
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 /dev/ulpt0. If
your printer has this problem, use the /dev/unlpt0 device
instead.
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
like this:
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,
select 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
default printer.
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
your own.
Finally, start lpd(8), the line printer spooler daemon. Ensure
that 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.
Showing messages 1 through 10 of 10.
-
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]
After much tweaking I'm finally printing with a HP LaserJet 4L thanks to this article. It wasn't straightforward (what is in UNIX?) but it does work.
A couple of things occurred on the journey that maybe someone can explain.
1) Apsfilter setup states it doesn't mess with the printcap. Hence, via the BSD handbook, I edited the /etc/printcap & added a printer AFTER I successfully printed a testpage with the Apsfilter setup. When I tried to print from Abiword OR Opera, nothing would print.
2) So, being the stubborn type that I am, I re ran the apsfilter setup. It found the current setup & asked if I wanted to create another file. For some reason I opted to create another profile & completed setup. I then immediately checked the /etc/printcap file & found that apsfilter HAD entered some information. I commented out my original entry, saved the file, opened Abiword & attempted to print. Voila!!!!!! Success!!!!! The same thing occurred with Opera.
3) The question is why?
-
Printing sucess at last
2004-10-31 04:33:50 MrBluez [View]
After much tweaking I'm finally printing with a HP LaserJet 4L thanks to this article. It wasn't straightforward (what is in UNIX?) but it does work.
A couple of things occurred on the journey that maybe someone can explain.
1) Apsfilter setup states it doesn't mess with the printcap. Hence, via the BSD handbook, I edited the /etc/printcap & added a printer AFTER I successfully printed a testpage with the Apsfilter setup. When I tried to print from Abiword OR Opera, nothing would print.
2) So, being the stubborn type that I am, I re ran the apsfilter setup. It found the current setup & asked if I wanted to create another file. For some reason I opted to create another profile & completed setup. I then immediately checked the /etc/printcap file & found that apsfilter HAD entered some information. I commented out my original entry, saved the file, opened Abiword & attempted to print. Voila!!!!!! Success!!!!! The same thing occurred with Opera.
3) The question is why?
-
doesn't work
2004-04-27 08:17:14 joepekoe [View]
This article did not help my printing needs on an HP1300 laserjet. Theoretically, apsfilter should work just fine with generic postscript since this printer supports postscript. But after following the instructions in this article to the letter, I get no printing from the printer. Worse, I get no error messages from apsfilter.
-
hahaha the irony of this article is just rich
2003-11-20 09:49:42 anonymous2 [View]
"Printing on a UNIX-like operating system has traditionally given headaches to even experienced sysadmins."
"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."
Last time I installed a printer with cups and gnome it took 10 seconds (20 with the apt-get), but by all means you should continue to use lpd and arcane setups for maximum l33tness.
-
RE: hahaha the irony of this article is just rich
2004-01-02 10:19:42 anonymous2 [View]
i have tried CUPS installations on a couple of sites (FreeBSD/Samba small office servers), and i always end up back with lpd. it's small, reliable, efficient, and effective. CUPS is a fine piece of software, but so is LPD.
-
Nice To See
2003-11-11 12:43:07 anonymous2 [View]
It's nice to see that others are using "apsfilter". I've been using it to support printers on OpenBSD systems. At home OpenBSD is my preferred choice for a NAT/DHCP Server/SPI firewall box. Along with the firewall I also find it useful to share our one and only laser printer in the house by using "apsfilter" on the firewall as well.
I know running services on a firewall is bad but with a reasonable set of PF rules in place it's possible to block access to running services from the WAN interface. Lets face it any box that runs as a print server needs to be on all of the time anyways and so does the firewall. No one wants to have to walk into our den and turn on a firewall or print server when they want to access the Internet or print something.
-
Nope, that's what I did.
2003-11-11 04:25:36 agshekeloh [View]
I didn't do anything except what was posted in the article, on a recent -current workstation. Apsfilter has worked out-of-the-box on FreeBSD for years, and is pretty durn reliable on the other open-source BSDs as well. The print spool permissions are unchanged for years now.
-
Re: permissions
2003-11-10 20:14:15 anonymous2 [View]
what part of "printing for the impatient" did you misunderstand? the topic wasn't "printing for the enterprise enviroment" so your comment about the home office printers is probably very correct.
I have used apsfilter for printing locally and over CIFS/SMB and have never had 'permission' problems, if you feel jaded about the authors paper I'll look forward to see your article submitted "printing for the enterprise?" didn't think so.
-
Permissions
2003-11-10 13:49:39 anonymous2 [View]
I was hoping this article would cover the usual gotcha when installing printing software: Permissions issues.
I have used apsfilter, LPRng, CUPS, and lpd, but I have always had to fight with permissions issues. If you've never heard of apsfilter, this is a nice intro, but won't get people setting up anything but home office printers. I can't help but feel cheated - I think the author is duping us! Printing on Unix is not easy! Get your hands dirty! Admit it, you gave up and bought a print server!







I run apsfilter SETUP and installed a remote printer. Test page was successfully printed. I restarted lpd and run lpr hai.txt command to print a simple textfile. But it is not working.
My lpq gives the following message,
Printer: lp@siddharth PS;r=360x360;q=medium;c=full;p=a4;m=auto' (dest lp@107.108.89.74)
Queue: no printable jobs in queue
Server: no server active
Status: job 'root@siddharth+229' saved at 14:21:39.170
Rank Owner/ID Pr/Class Job Files Size Time
error root@siddharth+229 A 229 ERROR: Mystery error from Send_job
JetDirect lpd: no jobs queued on the port Auto
My printcap file:
# APS_BEGIN:printer
# - don't delete start label for apsfilter printer
# - no other printer defines between BEGIN and END LABEL
lp|PS;r=360x360;q=medium;c=full;p=a4;m=auto:\
:lp=:\
:rm=107.108.89.74:\
:rp=lp:\
:if=/root/Desktop/apsfilter-distro/etc/apsfilter/basedir/bin/apsfilter:\
:sd=/var/spool/lpd/lp:\
:lf=/var/spool/lpd/lp/log:\
:af=/var/spool/lpd/lp/acct:\
:mx#0:\
:sh:
# APS_END - don't delete this
My /var/spool/lpd/lp/status.pr file:
processing 'dfA229siddharth.k', size 603, format 'f', IF filter 'apsfilter' at 2007-07-18-14:21:39.166 ## A=root@siddharth+229 number=229 process=3232
IF filter 'apsfilter' filter msg - 'Make_passthrough: pid 3233, execve '/root/Desktop/apsfilter-distro/etc/apsfilter/basedir/bin/apsfilter' failed - 'Exec format error''
IF filter 'apsfilter' filter exit status 'JABORT' at 2007-07-18-14:21:39.168 ## A=root@siddharth+229 number=229 process=3232
waiting for subserver to exit at 2007-07-18-14:21:39.169 ## A=<NULL> number=0 process=3231
job 'root@siddharth+229' error 'Mystery error from Send_job' at 2007-07-18-14:21:39.169 ## A=root@siddharth+229 number=229 process=3231
job 'root@siddharth+229' saved at 2007-07-18-14:21:39.170 ## A=root@siddharth+229 number=229 process=3231
Please try to solve my problem.