Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jul 2006 02:58:46 -0700
From:      "Ted Mittelstaedt" <tedm@toybox.placo.com>
To:        "doug" <doug@fledge.watson.org>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Printing to winprinters with LPR, no CUPS needed
Message-ID:  <001601c6a33e$4584f8c0$3c01a8c0@coolf89ea26645>
References:  <20060705073724.GC29631@lothlorien.nagual.st><004301c6a0bd$0d36dc00$3c01a8c0@coolf89ea26645><20060706155340.GA7731@lothlorien.nagual.st><002d01c6a19f$35bd7ac0$3c01a8c0@coolf89ea26645> <20060707125334.Q6216@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
So you don't like printing with CUPS or aspfilter or any of those
"hold-your-hand"
programs, eh?  Well, neither do I.

So you have a yucky winprinter which doesen't understand a Real Man's
printer control
language like any decent self-respecting printer does?  Well, so do I!

You can indeed print to these printers using just LPR plus the engine
programs
used to massage PostScript (which UNIX programs like Firefox generate) into
the gross binary dreck that Winprinters digest.

There are 3 keys to getting this working:

1) You must use a filter that calls gimpprint, gimpprint then calls
ghostscript.  You don't have
to use gimpprint - some HP inkjets are supported by a HP-written driver that
I believe
converts the IJS output of Ghostscript into the HP winprinter stuff - you
will need to play
around with this.  You MUST understand what gimpprint is doing!  Your going
to need to
modify a lot of the options passed to gimpprint by hand in order to get it
to work with your
printer.  Note that the command that runs gimpprint in the script is ALL ONE
LINE, and it
is really long!  It is wrapped in the examples here but I'm sure you can
figure this out.

Note that for a FEW printer models, you can not use gimpprint at all, just
use
Ghostscript.  For example, PCL-speaking printers.  Some inkjets.  This is
because Ghostscript
has drivers for these built right into Ghostscript.

The filter is really the heart of the whole thing.  CUPS prettifies all of
the different options that
are passed to gimpprint - you do not need to know, for example, that
"InkType=CMYK"
might need to be passed to gimpprint for your printer, because you just
click a button in
CUPS that does this.  That is great if your a plain old user that only has
point-and-click
skills.  It's hideous if your a network admin that wants to script anything,
and it's awful
if you want to know what the hell is really going on under the hood.

2) The filter must be an OUTPUT filter because the output of gimpprint is
NOT 7-bit ASCII
in any way, shape or form - it almost certainly is going to contain null
characters and other
such things that will stop any UNIX textprocessing programs cold.

3) You need to define multiple filters for different things you want your
printer to do.  For
example suppose you normally print color but your printer takes forever to
print a very
high res image like a photograph, and you just want to print colored
spreadsheets at a low
resolution.  So you would define 2 different filters, and put them on 2
different print queues,
when you want to print at low res, you print to one queue, when you want to
print high res,
you print to the other.

Now, to the instructions:

The sample here is my Epson Stylus C84 color inkjet printer.  I bought this
printer
for three reasons:  1) It has good support in gimpprint, 2) It has
individual ink resivors for
EACH color, so you don't have to chuck out a multi-ink cartridge just
because you
ran out of red. 3) It has a parallel interface in addition to USB.  So, I
plug my FreeBSD
box into the parallel port, and my wife's Windows box to the USB port, and
now I
don't have to fiddle faddle around with setting up a USB print server, etc.
As a bonus,
I found you can communicate with this printer to ask it how much
ink is left.  Also, as another bonus, the C84 does understand ASCII (but of
course, you
can't print in color or do any of the fancy stuff with just talking ASCII to
the printer)

1) Load and setup FreeBSD.  Install the ports directories.

2) Plug printer into parallel port.  Make sure "ls -l | /dev/lpt0" or "ls -l
| /dev/usb0" or
"ls -l | lpr -P mynetworkprinterialreadysetupinprintcap" makes the printer
do something,
even if it's nothing more than printing a few characters of garbage.

3) setup print queues  (don't worry about the filter "epsonfilter720x360"
yet we will get to that)

Add the following to the end of /etc/printcap:

lp-epson-720x360|Epson C84 Color printer:\
        :sh:\

:lp=/dev/lpt0:sd=/var/spool/output/lp-epson:lf=/var/log/lpd-errs:mx=0:\
        :of=/usr/local/bin/epsonfilter720x360:rw:
lp-epson-raw|Epson C84 Color Printer - raw for Windows systems spooling
through us and for testing:\
        :sh:\

:lp=/dev/lpt0:sd=/var/spool/output/lp-epson-raw:lf=/var/log/lpd-errs:\
        :mx#0:rw:

Create the print queues:

cd /var/spool/output
mkdir lp-epson
mkdir lp-epson-raw

Add in access for the local systems

vi /etc/hosts.lpd
#
# See lpd(8)
#machine.domain
putinmymachinesthatIwanttospoolthroughme

Run some test prints through the queues:

cd /etc
ls -l | lpr -P lp-epson
ls -l | lpr -P lp-epson-raw

Don't worry that nothing comes out yet, we are only testing to make
sure LPD is setup right.

Note there is a bug in lpd it creates the queue spools with the wrong
permissions
if your very first print is from the network, this is another reason why we
do
these tests locally first.

(may need to do a chmod 664 on the lock file in the queues, since network
LPR doesen't set the mask up properly per submitted bug)

4) Install the tools to image a printjob for the Epson, as follows:

cd /usr/ports/print/gimp-print
make WITHOUT_CUPS=yes
cd work/gimp-print-4.2.7/src/escputil
./escputil -i -u -r /dev/lpt0 (checks ink levels)
./escputil -n -u -r /dev/lpt0 (prints nozzle alignment)
(try some other commands to see if the level of support is better)
cd ../../../../
make WITHOUT_CUPS=yes install
cd ../ghostscript-gnu
make install
Deselect all the printers, leave in stp and ijs driver, as well
as all the X-windows drivers and the jpg and other image drivers.

test the ghostscript install:

cd /root
man -t which > which.ps
gs -dBATCH -sDEVICE=jpeg -sOutputFile=test.jpg which.ps
open test.jpg in a browser and see if the page is there

Now test gimpprint and ghostscript:

first manually with the command,

gs -sDEVICE=ijs -sIjsServer=/usr/local/bin/ijsgimpprint -sDeviceManufacturer
=EPSON  -sDeviceModel=escp2-c84 -sIjsParams=Quality=720x360sw,InkType=CMYK,M
ediaType=Plain -dIjsUseOutputFD -dNOPAUSE -dBATCH -sOutputFile=test.out
/usr/local/share/ghostscript/7.07/examples/colorcir.ps

lpr -P lp-epson-raw test.out


Create the file /usr/local/bin/epsonfilter720x360 with the following
contents:

#!/bin/sh
#
# Script that runs gimp-print for the Epson
#
/usr/local/bin/gs -q -sDEVICE=ijs -sIjsServer=/usr/local/bin/ijsgimpprint -s
DeviceManufacturer=EPSON  -sDeviceModel=escp2-c84 -sIjsParams=Quality=720x36
0sw,InkType=CMYK,MediaType=Plain -dIjsUseOutputFD -dNOPAUSE -dNOBATCH -dSAFE
R -sOutputFile=- -

test with firefox and use the printer lpr -P lp-epson
/usr/local/share/ghostscript/7.07/examples/colorcir.ps

5) Create any other print queues you want for different printer resolutions,
along with their respective
filters.  The filters will be the same except -sIjsParams=Quality= will be
set to a different
resolution file value

Ted




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001601c6a33e$4584f8c0$3c01a8c0>