#!/bin/sh # # foofilter.sh -- Foomatic-rip-lprng is used as the print filter # # Requires # poppler (xpdf): pdftops # foomatic-filters-lprng # enscript set -u # define temporary files infile="/tmp/infile.$$" tempfile="/tmp/tempfile.$$" # replace example.ppd with the appropriate ppd file for your printer your_ppd="${example}.ppd" # choose your paper size PAPER='Letter' #PAPER='A4' # send the standard input to a temporary file cat > "${infile}" # figure out what type of file we are trying to print fileinfo="$(file -b "${infile}")" # take various actions depending on the type of file -- send # results to a temporary postscript file case "${fileinfo}" in *ASCII*) enscript -M "${PAPER}" -o - "${infile}" > "${tempfile}" ;; *PDF*) pdftops "${infile}" - > "${tempfile}" ;; *PostScript*) cat "${infile}" > "${tempfile}" ;; *) echo "Cannot print file of type ${fileinfo}" | \ enscript -M "${PAPER}" -o - > "${tempfile}" ;; esac # foomatic-rip sends stuff to the standard output /usr/bin/foomatic-rip-lprng --lprng "/etc/lprng/lpd/${your_ppd}" < "${tempfile}" rm -f "${infile}" "${tempfile}"