xref: /freebsd/share/examples/printing/ifhp (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1#!/bin/sh
2#
3#  ifhp - Print Ghostscript-simulated PostScript on a DesJet 500
4#  Installed in /usr/local/libexec/hpif
5
6#
7#  Treat LF as CR+LF:
8#
9printf "\033&k2G" || exit 2
10
11#
12#  Read first two characters of the file
13#
14read first_line
15first_two_chars=`expr "$first_line" : '\(..\)'`
16
17if [ "$first_two_chars" = "%!" ]; then
18    #
19    #  It is PostScript; use Ghostscript to scan-convert and print it
20    #
21    /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - \
22        && exit 0
23
24else
25    #
26    #  Plain text or HP/PCL, so just print it directly; print a form
27    #  at the end to eject the last page.
28    #
29    echo "$first_line" && cat && printf "\f" && exit 0
30fi
31
32exit 2
33