View Single Post
  #7   (View Single Post)  
Old 12th March 2009
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by queenorych View Post

My printcap says:
lp|brother:\
:lp=:rm=192.168.1.2\
:rp=L1:sd=/var/spool/brother:\
:lf=/var/log/lpd-errs:\
:sh:\
:if=/usr/local/bin/lppsfilter:

and my /usr/local/bin/lppsfilter has:
/usr/local/bin/gs -q -dNOPAUSE -sDEVICE=pxlmono -sOutputFile=- -
I never bothered to get asci working, as I never use it personally.
That is the easiest way to do it although in your case I think your printer even speaks Post Script. Check one more time. Lots of Brother HL printers from series 5000 and above are full Post Script printers.

Now back to your Post Script filter. Actually to be precise it should be something like this.
Code:
#!/bin/sh
# Treat LF as CR+LF
printf "\033&k2G" || exit 2
# Print the postscript file
/usr/pkg/bin/gs -dSAFER -dBATCH -dQUIET -dNOPAUSE -q -sDEVICE=cdj550 \
-sOutputFile=- -sPAPERSIZE=a4 - && exit 0
exit 2
Just change the device driver cdj550 with your driver and the paper size a4 with letter if you live in U.S.A. The above script should have permission 0775. It must be executable by daemon and user from the daemon group.
Printcap as you said should look like
Code:
ps|Ghostscript driver:\
        :lp=/dev/lpa0:sd=/var/spool/lpd/ps:lf=/var/log/lpd-errs:\
        :mx#0:sh:if=/usr/local/libexec/lpfilter-ps:
Note that mx#0 is very important because post script files are usually huge. You correctly pointed out the importance of spooling directory with correct permissions. The above is described in NetBSD printer documentation. BSDs come with built in ASCII filter which is described in FreeBSD handbook. You do not need it. a2ps (filter) or enscript will convert ASCII to PostScript and you are good to go. I like very much what you did.
As I mentioned in one of my earlier messages Ghostscript comes which the script which can help you generate above filter. FreeBSD documentation (corporate guide chapter 8th talks about it).

I think you can use above also with hplip drivers and Guthenprint. It is just enough to substitute hpijs as a device name. I never used Guthenprint so I would not know if it works with it but I think it should. The only "problem" with the described approach is that if you send let say dvi or pdf file printer will remain mute.

Thus we come to the concept of text filters. Examples are apsfileter (with which I am very familiar) and magicfilter (not even ported to OpenBSD which I use). These filters are doing one more thing to you. They are able to recognize file type sent to the printer and convert it to post script file before sending to the driver. The converters are as you could expect. a2ps for ASCII. dvips for dvi to ps and pdf2ps for pdf to ps. Image Magic and in particular its command line utility convert is also very useful for various image files.


And speaking of warning of apsfilter regarding the Ghostscript version. Ignore it. It is actually little stale project so apsfilter see new versions of Ghostscript as outdated. So some Perl scripts which make apsfilter need to be updated but other than that apsfilter is ROCK solid. As I said I have no experience with magic filter which is hard coded in C.

Last edited by Oko; 14th March 2009 at 03:27 AM.
Reply With Quote