#! /bin/sh # Author: Pierre A. Humblet pierre.humblet@ieee.org # Created: May 2000 # Modified: March 2001 Add support for gsprint # Modify and redistribute freely. Use at your own risk. # This is distributed as part of the Xfig-Cygwin package. # # Modified: Igor Pechtchanski pechtcha@cs.nyu.edu # Modified: February 2002 Add support for -P and $PRINTER # Modified: February 2002 Add support for stdin # Modified: March 2002 Disable gsprint support # Modified: May 2002 Tweak gs options # Modified: August 2002 Add -Q and -h; make presentable # # Script to print postscript from stdin or the file given as # single argument. # Relies on the existence of gsprint # ( http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm ) # or of gs (ghostscript) with device mswinpr2 # #GSLP=gslp.ps GSLP=`cygpath -w /usr/local/bin/gslp.ps` USAGE="\ Usage: $0 [--help] [--query|-Q] [--printer |-P |-P] [file_1 .. file_n]" while [ $# -gt 0 ]; do case "$1" in -h | --help) shift; echo "$USAGE"; exit 0 ;; -Q | --query) shift; QUERY=true ;; -P | --printer) shift; PRINTER="$1"; shift if [ -z "$PRINTER" ]; then echo Please specify a printer with -P 1>&2 exit 2 fi ;; -P*) PRINTER="${1#-P}"; shift ;; --) shift; break ;; -*) echo "$0: $1: invalid option" 1>&2 echo "$USAGE" 1>&2 exit 2 ;; *) break ;; esac done if [ "${1:-}" = "" ] then # file=-_ file='%stdin' else file="$1" if [ ! -r "$file" ] then file="${file}.ps" if [ ! -r "$file" ] then echo Cannot read "$file" 1>&2 exit fi fi file=`cygpath -w "$file"` fi #echo "Printing '${file}' to $PRINTER" # Look for Ghostgum Gsview in the registry GSPRINT="" VERSIONS=`regtool -q list '\HKLM\SOFTWARE\Ghostgum\Gsview'` # Scan all versions, keep the last good one for VER in ${VERSIONS} do WHERE_W=`regtool -q get '\HKLM\SOFTWARE\Ghostgum\Gsview\'"${VER}"` if [ -n "$WHERE_W" ] then WHERE_U=`cygpath -u "$WHERE_W"` GSPRINT_CAND="${WHERE_U}/gsview/gsprint.exe" if [ -x "$GSPRINT_CAND" ] then # GSPRINT="${GSPRINT_CAND}" fi fi done # Escape backslashes in $PRINTER PRINTER=`echo $PRINTER | sed 's/\\\\/\\\\\\\\/g'` if [ -n "$GSPRINT" ] then # Use gsprint PRINTSTR="" if [ -n "$PRINTER" ] then PRINTSTR="-printer $PRINTER" fi echo "${GSPRINT}" -q -query $PRINTSTR "${file}" "${GSPRINT}" -q -query $PRINTSTR "${file}" else # Try gs if [ -n "$PRINTER" ] then PRINTSTR='/OutputFile (\\\\spool\\'"$PRINTER"')' elif [ -n "$QUERY" ] then PRINTSTR='/QueryUser 1' else PRINTSTR='/QueryUser 3' fi # echo "Printing '${file}' to $PRINTER using gs -dNOPAUSE -dBATCH -q -c mark /NoCancel true $PRINTSTR /UserSettings '<<' /MaxResolution 1200 '>>' '(mswinpr2)' finddevice putdeviceprops setdevice -f -sPROGNAME=lpr -- $GSLP --detect -B ${file}" gs -dNOPAUSE -dBATCH -q -c mark /NoCancel true "$PRINTSTR" /UserSettings '<<' /MaxResolution 1200 '>>' '(mswinpr2)' finddevice putdeviceprops setdevice -f -sPROGNAME=lpr -- $GSLP --detect -B "${file}" fi # This worked: "gs -dNOPAUSE -dBATCH -q -sDEVICE=mswinpr2 -r600 '-sOutputFile=\\spool\$PRINTER' -dNoCancel -sPROGNAME=gslp -- gslp.ps ${file}" # So did this: "gs -dNOPAUSE -dBATCH -q -c mark /NoCancel true /QueryUser 3 /OutputFile '(\\spool\lp.scs.cs.nyu.edu)' /UserSettings '<<' /MaxResolution 1200 '>>' '(mswinpr2)' finddevice putdeviceprops setdevice -f -sPROGNAME=gslp -- gslp.ps ${file}"