Subject: Re: [port-i386@NetBSD.org] hp deskjet 3745
To: NetBSD Port-i386 Users <port-i386@NetBSD.org>
From: Robert Zagarello <bzag0@yahoo.com>
List: port-i386
Date: 06/16/2005 20:45:00
I apologize if this list is stream-of-consciousness
disorganized, but it does follow what I had to do, in
serial order.

The HP printer I use is on a print server adapter, so
the "connector" is actually a hostname in lpfilter*.
You would have to specify the valid USB device if your
 printer is connected via USB.  (I did not try USB.)

(Also, comments below are notes which are not
specifically tailored for anyone but myself.  Hope
this helps.  Good luck....  BZAG.)


==========================
PRINTER SETUP in NetBSD OS
==========================
FOLLOW THE GUIDE, WHICH IS, IN SUMMARY:
0.  lpd daemon control is /etc/rc.d/lpd start and stop
1.  Edit /etc/printcap to specify printers - note this
file is overwritten if cupsd is also started!!
2.  Create directory trees for /var/spool/output/lpd
and set proper protections
3.  Create lp filters in /usr/pkg/libexec with chmod
755
4.  Setup remote-IP printer and Postscript-to-PCL
printer using Ghostscript
5.  FOLLOW THE GUIDE WITH THE FOLLOWING EXCEPTIONS:

The Spool directory is /var/spool/output/lpd NOT
/var/spool/lpd.

I made the dir/file ownership from lpd on-down
daemon:users instead of daemon:daemon.

/etc/printcap file:
------------------
# HP DeskJet 560C on PS101 Network Port
# SET THIS AS THE DEFAULT PRINTER FOR THE COMMAND LINE
#  USING PRINTER=hp.
hp|HP Deskjet:\
:lp=9100@hp560c:sd=/var/spool/output/lpd/hp:lf=/var/log/lpd-errs:\
:sh:pl#66:pw#80:if=/usr/pkg/libexec/lpfilter:

# Ghostscript Printer to Convert from Postscript to
#  Deskjet 550 PCL via lpfilter-hpps.  SET THIS AS THE
#  DEFAULT PRINTER IN KDE USING PRINT MANAGER.
hpps|Ghostscript driver:\
:lp=9100@hp560c:sd=/var/spool/output/lpd/hpps:lf=/var/log/lpd-errs:\
:mx#0:sh:if=/usr/pkg/libexec/lpfilter-hpps:

# Same as hpps but without the extra formfeed in the
#  filter, for KDE only.
khpps|Ghostscript Driver for KDE:\
:lp=9100@hp560c:sd=/var/spool/output/lpd/khpps:/var/log/lpd-errs:\
:mx#0:sh:if=/usr/pkg/libexec/lpfilter-khpps:

The lpfilter and lpfilter-hpps files needed mods to
 provide a formfeed at the end of the job, example
 below is for lpfilter.  Note all printf codes are in
 OCTAL !!

/usr/pkg/libexec/lpfilter file:
-------------------------------
#!/bin/sh
# Treat LF as CR+LF
printf "\033&k2G" && cat && printf "\014" && exit 0
exit 2


/usr/pkg/libexec/lpfilter-hpps file:
------------------------------------
#!/bin/sh
# Treat LF as CR+LF
printf "\033&k2G" && exit 0 || exit 2
# Print the postscript file
/usr/pkg/bin/gs -dSAFER -dBATCH -dQUIET -dNOPAUSE -q \
 -sDEVICE=cdj550 -sOutputFile=- -sPAPERSIZE=letter \
 - && printf "\014" && exit 0
exit 2

/usr/pkg/libexec/lpfilter-khpps file:
------------------------------------
#!/bin/sh
# Treat LF as CR+LF
printf "\033&k2G" && exit 0 || exit 2
# Print the postscript file
/usr/pkg/bin/gs -dSAFER -dBATCH -dQUIET -dNOPAUSE -q \
 -sDEVICE=cdj550 -sOutputFile=- -sPAPERSIZE=letter \
 - && exit 0
exit 2

NOTE THE GUIDE USES /usr/local/libexec WHEREAS THE
PROPER DIRECTORY IS /usr/pkg/libexec

Define PRINTER in the environment as "hp"

Add hp560c to the hosts file

Note "letter" was used for PAPERSIZE above instead of
a4 (which is what the Guide uses)
The PAPERSIZE params can be obtained from man gs.

The Postscript Ghostscript driver in lpfilter-hpps
takes Postscript files as input and prints PCL
   (using sDEVICE=cdj550 = convert deskjet 550 !!) 
Perhaps there are other drivers available in man gs
for the sDEVICE param/

For lpr to work without explicitly specifying the
printer on the command line the param PRINTER must be
defined in the environment:
  lpr -P hp     IS THE SAME AS     lpr
  when PRINTER=hp
  because "hp" is defined in printcap.

-------------------------------------------------------
6.  Standard text test:
    Local parallel port: lptest 70 5 > /dev/lpt0
    USB port   lptest 70 5 > /dev/ulpn0
7.  Standard test to printer daemon is:
    lptest 70 5 | lpr -hP <printer defined in
printcap>

(The -P option is required if PRINTER is not defined
in the environment.)

8.  Remote Printing refers to
hostname:printersharename rather than strict IP
printing.

=================
KDE Print Manager
=================
DO NOT USE THE LPD SYSTEM AS THE "PRINT SYSTEM"
DEFAULT IN KDE:

0.  Set PRINTER=khpps as default for account
<username> (the account in which KDE is run)
1.  In KDE Print Manager, select "Print Through an
External Program (generic)"
2.  Set default KDE Printer = PS_Printer
3.  When printing, set command to lpr -h so that the
PS output goes to khpps (the default PRINTER)
4.  The above was tested with KWrite and Firefox.