Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Oct 2000 13:38:54 +0100
From:      Mark Ovens <marko@freebsd.org>
To:        Chris Hill <chris@monochrome.org>
Cc:        Matthew Rochlin <rochlin@mediaone.net>, FreeBSD Questions List <freebsd-questions@freebsd.org>
Subject:   Re: HP Laserjet with JetDirect Network card -- how-to
Message-ID:  <20001008133854.C253@parish>
In-Reply-To: <Pine.BSF.3.96.1001008005728.69903A-100000@localhost>; from chris@monochrome.org on Sun, Oct 08, 2000 at 01:24:29AM -0400
References:  <4.3.2.7.2.20001007140207.0189db68@pop3.norton.antivirus> <Pine.BSF.3.96.1001008005728.69903A-100000@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Oct 08, 2000 at 01:24:29AM -0400, Chris Hill wrote:
> On Sat, 7 Oct 2000, Matthew Rochlin wrote:
> 
> > Thanks for your suggestion...
> > 
> > It works (mostly), but only on postscript files. (I don't have ghostscript 
> > or any other postscript generating tool on my BSD machine at the moment,
> 
> If you have a Postscript printer, you don't need ghostscript, except
> maybe for viewing PS on-screen. gs allows a non-PS printer to print PS
> files. PS printers used to be very expensive due to Adobe's high
> licensing fees.
> 
> > lpr test.prn
> > 
> > Printed out the document (your email, actually) fine.    But if I try to 
> > print plain text, I get just the first line, somewhat garbled at the end 
> > (the next two lines print out shifted to the far right and the rest of the 
> > document doesn't print at all).
> 
> The infamous stairstep effect! This happens because a unix newline is a
> single LF character, where the printer is probably expecting a CR and an
> LF like what DOS produces.  I'll bet if you try to print a plain text
> file with one word per line,
> it
>    will
>         look
>              like
>                   this.
> 
> Having said that, I don't remember how to fix it but if you search the
> archives under "staircase" or "stairstep" you should turn up something.
> It was a simple fix, I just don't recall what it was.
> 

Not sure if this will work with a PS HP printer but since they also support
PCL it should do. Add

	:if=/usr/local/libexec/hpif:

to the /etc/printcap entry and put this in /usr/local/libexec/hpif:

#
#  Read first two characters of the file
#

read first_line
first_two_chars=`expr "$first_line" : '\(..\)'`

if [ "$first_two_chars" = "%!" ]; then

        #
        #  It is PostScript; use Ghostscript to scan-convert and print it.
        #
        #  Note that PostScript files are actually interpreted programs,
        #  and those programs are allowed to write to stdout, which will
        #  mess up the printed output.  So, we redirect stdout to stderr
        #  and then make descriptor 3 go to stdout, and have Ghostscript
        #  write its output there.  Exercise for the clever reader:
        #  capture the stderr output from Ghostscript and mail it back to
        #  the user originating the print job.
        #
        exec 3>&1 1>&2
        /usr/local/bin/gs -dSAFER -sPAPERSIZE=a4 -dNOPAUSE -q \
                -sDEVICE=cdj550 -sOutputFile=/dev/fd/3 - && exit 0

else

        #
        #  Plain text or HP/PCL, so just print it directly; print a form
        #  at the end to eject the last page.
        #
        printf "\033&k2G" && echo $first_line && cat && \
                printf "\033&l0H" && exit 0
fi

ESC&k2G is the PCL escape sequence to make the printer to interpret LF as
CR/LF and ESC&l0H resets it.

Since this is a PS printer you will need to change the line starting
``/usr/local/bin/gs'' to something like:

	echo $first_line && cat && exit 0

	
> > Is there maybe something I need to do to distinguish plain text from 
> > postscript?
> 
> Not on my printer; it seems to recognize the Postscript header and deal
> with it automagically. PS or plain text, I just do a 'lpr filename' and
> it works.
> 
> > Thanks!
> > (PS -- I also had to enable the printer spool daemon in 
> > /etc/rc.conf  ...  lpd_enable="YES" ... per the Almost Complete 
> > FreeBSD.  Not enabled by default on my system.  Maybe an installation 
> > option I missed?)
> 
> Woops, I forgot about that - sorry! It's been a while. I think the
> reason it's not on by default is that a) most things aren't in FreeBSD
> and b) lots of systems, e.g. servers, don't have or need a printer.
> 
> PS - you should copy replies to the list (which I have done here). Most
> of these folks know a lot more than I do. 
> 
> --
> Chris Hill               chris@monochrome.org
> [1]    Bus error                     netscape
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

-- 
		4.4 - The number of the Beastie
________________________________________________________________
51.44°N  FreeBSD - The Power To Serve http://www.freebsd.org
2.057°W  My Webpage http://ukug.uk.freebsd.org/~mark
mailto:marko@freebsd.org                http://www.radan.com



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001008133854.C253>