Merge branch 'vendor/MDOCML'
[dragonfly.git] / share / examples / printing / if-gs-ljet4
1 #!/bin/sh
2 #
3 # Printer filter for postscript or plain text with output to a HP laserjet.
4 # This requires two packages to be installed: 
5 #
6 #       /usr/dports/print/ghostscript9 (or later)
7 #       /usr/dports/print/enscript
8 #
9 # lp|ps|local line printer:\
10 #       :sh:mx#0:sf:\
11 #       :lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:\
12 #       :if=/usr/local/libexec/if-gs-ljet4:
13
14 read first_line
15 first_two_chars=`expr "$first_line" : '\(..\)'`
16
17 if [ "$first_two_chars" = "%!" ]; then
18    #
19    #  PostScript job, print it.
20    #
21    (echo "$first_line" && cat && exit 0) | \
22         gs -q -sPAPERSIZE=letter -sDEVICE=ljet4 -sOutputFile=%stdout% -
23    # printf "\004"
24    exit 2
25 else
26    #
27    #  Plain text, convert it, then print it.
28    #
29    ( echo "$first_line"; cat ) | /usr/local/bin/enscript -G | \
30         gs -q -sPAPERSIZE=letter -sDEVICE=ljet4 -sOutputFile=%stdout% -
31    # printf "\004"
32    exit 2
33 fi