NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Printing to networked printers?



Paul Goyette <paul%whooppee.com@localhost> wrote:

> ..
> In times gone by, I've had directly-connected HP printers and they
> just worked with lpr (plus print/magicfilter from pkgsrc).  But I
> cannot seem to get it to work with a network-connected HP DeskJet
> 2545.  I've "cloned" the /usr/pkg/libexec/magicfilter/dj550c-filter
> for my 2545 (and I added a line for sending %PDF to ghostscript,
> but have not gotten that far yet).  I've added a printer entry in
> /etc/printcap with the device set to "lp=9100@192.168.1.250"
> (using the "raw" port as shown in an earlier commented-out example
> line).
>
> I've confirmed that my filter (or at least, a filter) is being
> invoked, since the "default" entry for plain text, simply uses a
> directive to send a prefix string, the plain text, and a suffix.
> I have confirmed using tcpdump that all three are being sent to
> the printer.
>
> But still nothing gets printed.
> ..

Yeah, printers/printing can be frustrating..

I've been using a crusty old HPLJ PCL-only printer for years with
the following setup:

--
The following was done to enable traditional lpd-based printing on NetBSD:
(note: you'll need to install ghostscript for PostScript printing)

1) create /etc/printcap entry:

# sudoedit /etc/printcap
...
# HP Laserjet 2100 on HP JetDirect print server on LAN @ 192.168.1.12:
lp|hplj-2100:\
        :sh:\
        :sd=/var/spool/output/lpd/hplj-2100:\
        :rm=192.168.1.12:\
        :rp=PORT1:\
        :lf=/var/log/lpd-errs:\
        :lp=/dev/null:\
        :if=/usr/local/lib/if-hplj_2100:\
        :mx#0:


2) create input filter /usr/local/lib/if-hplj_2100:

# sudoedit /usr/local/lib/if-hplj_2100

  #!/bin/sh
  #  ifhp - Print Ghostscript-simulated PostScript on a HP LaserJet 2100
  # -- revisions --
  # swapped "lj5gray" for "ljet4" for higher (1200 dpi) resolution option
  # swapped "ljet4" for "pxlmono" due to papersize problems
  # ---------------
  #
  # For plain-text files:
  printf "\033&k2G" || exit 2

  # For PS files:
  IFS=""
  read -r first_line
  first_two_chars=`expr "$first_line" : '\(..\)'`

  if [ "$first_two_chars" = "%!" ]; then
       exec 3>&1 1>&2
       /usr/pkg/bin/gs -dSAFER -dNOPAUSE -dBATCH -dQUIET -q -sDEVICE=lj5gray \
           -sOutputFile=/dev/fd/3 -sLETTERSIZE=letter -_ && exit 0
  else
       # For PCL files:
       echo "$first_line" && cat && printf "\033&l0H" && exit 0
  fi
  exit 2

2.1) ..and set the proper permissions:

# sudo chmod 755 /usr/local/lib/if-hplj_2100


3) create spool file /var/spool/output/lpd/hplj-2100:

# sudo mkdir /var/spool/output/lpd/hplj-2100


4) enable lpd in /etc/rc.conf:

# sudoedit /etc/rc.conf
...
# enable Line Printer Daemon:
lpd=YES	  lpd_flags="-lrs"    # -s use secure domain only
                              # -r allow print filters
                              # -l enable logging

5) start lpd daemon:
# sudo /etc/rc.d/lpd start

--

I've also experimented with "raw" printing using ncat(1) plus gs(1) if
printing a PS/PDF file):

% cat cat_sitter.ps | /usr/local/lib/if\-hplj_2100 | ncat 192.168.1.12 9100

This works pretty well for occasional use.


Lastly, some HP printers have an FTP server running where you can basically
just upload a file and the file prints.  Mine does and will print plain text
and PCL files just fine that way.

Hope this helps,

Jeff W.


Home | Main Index | Thread Index | Old Index