| 1 | #!/bin/sh |
| 2 | # Convert DVI to PDF. |
| 3 | # |
| 4 | # Please contact Andrew Ford <[email protected]> with any questions |
| 5 | # about this file. |
| 6 | # |
| 7 | # Based on ps2pdf |
| 8 | |
| 9 | # This definition is changed on install to match the |
| 10 | # executable name set in the makefile |
| 11 | GS_EXECUTABLE=gs |
| 12 | |
| 13 | |
| 14 | OPTIONS="" |
| 15 | DVIPSOPTIONS="" |
| 16 | while true |
| 17 | do |
| 18 | case "$1" in |
| 19 | -R*) DVIPSOPTIONS="$DVIPSOPTIONS $1";; |
| 20 | -z) DVIPSOPTIONS="$DVIPSOPTIONS -z" ;; |
| 21 | -pp) shift; DVIPSOPTIONS="$DVIPSOPTIONS -pp $1" ;; |
| 22 | -p) shift; DVIPSOPTIONS="$DVIPSOPTIONS -p $1" ;; |
| 23 | -t) shift; DVIPSOPTIONS="$DVIPSOPTIONS -t $1" ;; |
| 24 | -T) shift; DVIPSOPTIONS="$DVIPSOPTIONS -T $1" ;; |
| 25 | -l) shift; DVIPSOPTIONS="$DVIPSOPTIONS -l $1" ;; |
| 26 | -?*) OPTIONS="$OPTIONS $1" ;; |
| 27 | *) break ;; |
| 28 | esac |
| 29 | shift |
| 30 | done |
| 31 | |
| 32 | if [ $# -lt 1 -o $# -gt 2 ]; then |
| 33 | echo "Usage: `basename \"$0\"` [options...] input.dvi [output.pdf]" 1>&2 |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | infile=$1; |
| 38 | |
| 39 | if [ $# -eq 1 ] |
| 40 | then |
| 41 | case "${infile}" in |
| 42 | *.dvi) base=`basename "${infile}" .dvi` ;; |
| 43 | *) base=`basename "${infile}"` ;; |
| 44 | esac |
| 45 | outfile="${base}".pdf |
| 46 | else |
| 47 | outfile=$2 |
| 48 | fi |
| 49 | |
| 50 | # We have to include the options twice because -I only takes effect if it |
| 51 | # appears before other options. |
| 52 | exec dvips -Ppdf $DVIPSOPTIONS -q -f "$infile" | $GS_EXECUTABLE $OPTIONS -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr -sOutputFile="$outfile" $OPTIONS - |