[wellylug] More fun with printers
Pete Black
pete at marchingcubes.com
Sat Jan 8 20:57:50 NZDT 2005
a2ps might come in handy for this kind of thing too
>In a prior post I mentioned printing directly to /dev/lp0 using cat,
>for the case where printing utilities are not available. It might
>also be useful for testing when there is a chance CUPS/lpd/lprng might
>be misconfigured.
>
>Anyhow, I said that I had found out how to do it with PCL5 printers
>but not postscript.
>
>I have found a way to do postscript. Okay, this is not elegant, but
>it should work for plain text files 50 lines or less. With some
>tweaking (I can't be bothered right now) multipage would be possible
>I'm sure -- just a matter of resetting pos every time it gets to 50
>lines and inserting a postscript page command:
>
>echo -e '%\!PS\n/Times-Roman findfont\n15 scalefont\nsetfont\n' >
>/dev/lp0 && pos=0 && cat FILETOPRINT | fold --width=70 -s | pr
>--length=50 | sed -e 's$\(\\\)$\\\\\\\1$g' | sed -e
>'s/\([()]\)/\\\\\1/g' | sed -e 's/^\(.*\)$/(\1) show/' | while read i
>; if [ $? -ne 0 ]; then exit; fi; pos=$(($pos+1)); do echo "36
>$((841-$pos*15)) moveto $i" > /dev/lp0 ; echo -e "\n" > /dev/lp0 ;
>done && echo 'showpage' > /dev/lp0
>
>It only requires sed/echo/a shell (or busybox) and textutils.
>
>I can't really test it as I don't have a ps printer. But ghostscript
>is happy with it.
>
>So there we are -- printing from the command line for both HP Ljet and
>PS printers. Ideal for the space/resource constrained, or if you need
>to test your printer.
>
>
>
More information about the wellylug
mailing list