Solved FreeBSD 10 ; Network printer and LPR

Hello everybody!

I'm trying to set up my network printer (HP Officejet 6700 premium) on FreeBSD 10.
Basically, I've got a router and I'm connected to it by ethernet. The printer is on WIFI.
I've installed temporarily print/hplip to get the correct .ppd file.
Here are my configured files:

/etc/printcap
Code:
lp|HP743C66;r=600x600;q=medium;c=full;p=a4;m=auto:\
        :lp=9100@HP743C66:\
        :if=/usr/local/etc/apsfilter/basedir/bin/apsfilter:\
        :sd=/var/spool/lpd/lp:\
        :lf=/var/log/lpd-errs:\
        :af=/usr/local/etc/ppd/hp-officejet_6700.ppd:\
        :mx#0:\
        :sh:
File checked with chkprintcap and everything is OK.

/etc/hosts
Code:
::1        localhost localhost.my.domain
127.0.0.1  localhost localhost.my.domain
<printer IP> HP743C66

/etc/devfs.rules : Here, I'm not sure about the wheel group
Code:
[system=10]
add path 'unlpt*' mode 0660 group wheel
add path 'ulpt*' mode 0660 group wheel
add path 'lpt*' mode 0660 group wheel
add path 'usb/*' mode 0660 group wheel
add path 'ugen*' mode 0660 group wheel

/etc/rc.conf
Code:
...
lpd_enable="YES"
devfs_system_ruleset="system"
...

And finally allowing the 9100 TCP port in PF
/etc/pf.conf
Code:
...
printer=<pinter ip>
printer_port="9100"
...
pass in on $ext_if proto tcp from ($ext_if) port $printer_port to $printer flags S/SA modulate state
pass out on $ext_if proto tcp from $printer to ($ext_if) port $printer_port flags S/SA modulate state

When trying to print from the command line a .pdf or .txt file, nothing happens and /var/log/lpd-errs shows:
Code:
May 25 14:47:41 <ComputerName> lpd[14007]: lpd startup: logging=0

I'm also able to ping the printer.

Do you have any idea on how to get this thing up and running? (It doesn't work even withoutPF enabled)

EDIT:
/var/spool/lpd is in daemon group; owner is root
/var/log/lpd-errs is in wheel group; owner is root

Thanks!

PS: I don't want to install CUPS and everything related to it. By the way, using CUPS (with the ppd file from hplip) doesn't work either as I always have a "filter failed" error. Anyway, I'm just interested in the LPR solution as CUPS has too many dependencies.
 
Re: FreeBSD 10 ; Network printer and LPR

Does the printer support plain text? If so, the first test can be just sending a text file directly to the printer without using lpd(8) at all:

nc HP743C66 9100 < `lptest`

If that prints something, the problem is with the lpd(8) setup. A simplified printcap without apsfilter would be the next thing to test.

The devfs.rules aren't needed unless you want to use USB or another local interface for connecting the printer.
 
Re: FreeBSD 10 ; Network printer and LPR

Thank you very much.

Your command is working and the text file is printed out.

However, even after commenting the line with the ppd file (which, in fact, has to be use with CUPS so I won't use it after all) and the one with apsfilter, printer still doesn't do a thing.

I really don't know what else to do.
 
Re: FreeBSD 10 ; Network printer and LPR

It doesn't always work to comment out lines in that file, because it's really one very long line. Try this:
Code:
lp:\				
	:lp=9100@HP743C66:\
	:sh:\
	:mx#0:\
	:sd=/var/spool/lpd/lp:
	:lf=/var/log/lpd-errs:
 
Re: FreeBSD 10 ; Network printer and LPR

Thank you very much! I removed those two lines instead of commenting them (which makes a lot of sense because of the "\") and now, it's printing.
 
Hey Juh924, are you still around?

I'm in the same situation as you... OfficeJet 6700 on the network and I can only get mine to print regular ASCII, if I send it .pdf or .ps I get pages and pages of garbage.

Were you able to get this printer to print postscript without installing CUPS?

Code:
OfficeJet:\               
    :lp=9100@OfficeJet:\
    :sh:\
    :mx#0:\
    :sd=/var/spool/lpd/officejet:\
    :lf=/var/log/lpd-errs:\
    :if=/usr/local/libexec/lf2crlf:

I'm pretty sure my spool directories are all set up because I can run

pkg info | lpr -P OfficeJet

and I get a list of my installed packages.
lf2crlf is OK, both printers use it and it solves the stair stepping.

ghostscript is installed but I don't know how to test it.

I already tried to use the ps2pcl filter but that doesn't work either.

This printer worked on my last server but that one had CUPS installed and I was hoping to avoid that this time around.
 
HP inkjets almost never understand PostScript, so you will have to use ps2pcl. Have you followed the printing section in the Handbook? When it doesn't work, what does it actually do?
 
Hi wblock

I was following the handbook, section 9.5.

I'd like to point out to anyone who is having trouble setting up their printer that you can save a lot of typing if you create a file called /usr/local/libexec/test.ps using the code from the example

Code:
%!PS

/Helvetica
findfont 18
scalefont
setfont
72 432 moveto
(PostScript printing successful.) show
showpage

Then I just used the command lpr -P OfficeJet test.ps

OK, now to the solution...I just found my mistake,

The example given to create your ps2pcl file is:

Code:
#!/bin/sh
/usr/local/bin/gs -dSAFER -dNOPAUSE -dBATCH -q -sDEVICE=ljet4 -sOutputFile=- -

but I've got an inkjet and it wasn't apparent to me that
Code:
-sdevice=ljet4
was referring to a ghostscript driver. I just thought it was because the example was for a ljet4.

I wasn't until I did some googling outside of these forums that I saw mention of the command gs -h to see all the drivers, then it eventually dawned on me that that's what
Code:
-sdevice=ljet4
was about.

The doc could use a little revision IMO since the example reads as if the code will work for any printer when in fact it will only work for laserjets and there is no mention that a gs driver should be chosen to match your printer.

In the end I chose
Code:
deskjet
and it made the 6700 purr to life.

My ps2pcl file is:

Code:
#!/bin/sh
/usr/local/bin/gs -dSAFER -dNOPAUSE -dBATCH -q -sDEVICE=deskjet -sOutputFile=- -

I hope this helps someone else who is stuck!

Thank you!
 
Additional info:

By Trial and error I also found that
Code:
#!/bin/sh
/usr/local/bin/gs -dSAFER -dNOPAUSE -dBATCH -q -sDEVICE=pcl3 -sOutputFile=- -

works, but even better is
Code:
#!/bin/sh
/usr/local/bin/gs -dSAFER -dNOPAUSE -dBATCH -q -sDEVICE=cdjcolor -sOutputFile=- -

Since the resolution is better and the color works, (pcl3 and deskjet are B&W)
 
The problem with examples is making them general enough to work for most people and not obscuring the main points with too many tangentially related details. We could say that the drivers could be set differently, but that leads the reader off to figure out which drivers are available and which one is needed for their printer. It could also leave them with a file called ps2pcl that does not actually produce PCL.

A section with a bunch of filters as a reference could be nice.
 
Something simple like this would have saved me a couple of hours of banging my head on the wall...
(Changes highlighted in green.)



9.5.3.3. Printing PostScript® to PCL Printers()

Many programs produce PostScript® documents. However, inexpensive printers often only understand plain text or PCL. This filter converts PostScript® files to PCL before sending them to the printer.

Install the Ghostscript PostScript® interpreter, print/ghostscript9, from the Ports Collection.

Create /usr/local/libexec/ps2pcl with these contents:

Code:
#!/bin/sh
/usr/local/bin/gs -dSAFER -dNOPAUSE -dBATCH -q -sDEVICE=xxxx -sOutputFile=- -
-sDEVICE=xxx represents the ghostscript driver for your printer,
# gs -h
will give you a list of what's available and you must match the driver to your printer.
(Look closely most of the driver names are pretty descriptive.)


Set the permissions and make it executable:

# [B]chmod 555 /usr/local/libexec/ps2pcl[/B]
PostScript® input sent to this script will be rendered and converted to PCL before being sent on to the printer.

Modify /etc/printcap to use this new input filter:
Code:
:if=/usr/local/libexec/ps2pcl:\
Test the filter by sending a small PostScript® program to it:

% [B]printf "%%\!PS \n /Helvetica findfont 18 scalefont setfont \
72 432 moveto (PostScript printing successful.) show showpage \004" | lpr[/B]
 
Back
Top