#!/bin/ksh93 # dvipdft, completely rewritten by Thomas Esser for teTeX after an # original script by Mark A. Wicks # # Modified by Matthias Franz for dvipdfmx/dvipdfm and TeX Live. typeset VERSION=20090604.0046 typeset -r FPROG=${.sh.file} typeset -r PROG=${FPROG##*/} SDIR=${FPROG%/*} function showUsage { [[ -n $1 ]] && X='-?' || X='--man' getopts -a ${PROG} "${ print ${USAGE} ; }" OPT $X } function doMain { [[ -z $1 ]] && showUsage 1 && exit 1 typeset DVIFILE="$1" OUTBASE LIST X shift # set trap for error trap 'print -u2 "${PROG}: fatal error." ; exit 1' # outfile comes from -o argument, else it is derived from the input file [[ -z ${PDFFILE} ]] && X="${DVIFILE%.dvi}.pdf" && PDFFILE="${X##*/}" # outBase is part of the thumbname files just as dvipdfm expects them: OUTBASE="${PDFFILE%.pdf}" LIST= for X in ~(N)"${OUTBASE}".[1-9]* ; do [[ -n $X ]] && LIST+=",${X##*/}" done if [[ -n ${LIST} ]]; then print -u2 "${PROG}: Please move the following files out of the way:" \ "\n\t${OUTBASE%/*}/{${LIST:1}}" exit 1 fi # set trap for cleanup trap 'rm -f "${OUTBASE}".[1-9]*' EXIT # Run dvipdfm with the fastest options for the first pass print -u2 "${PROG}: running dvipdfm $@ -z0 -o ${PDFFILE} ${DVIFILE}" dvipdfm "$@" -o "${PDFFILE}" -z0 "${DVIFILE}" # run gs print -u2 "${PROG}: running gs" gs -r10 -dNOPAUSE -dBATCH -sDEVICE=png256 -sOutputFile="${OUTBASE}.%d" \ "${PDFFILE}" # run dvipdfm with the users specified options for the last pass print -u2 "${PROG}: running dvipdfm $@ -o ${PDFFILE} -t ${DVIFILE}" dvipdfm "$@" -o ${PDFFILE} -t "${DVIFILE}" } USAGE='[-?'"${VERSION}"' ] [-author?Mark A. Wicks (original script).] [-author?Thomas Esser (rewrite).] [-author?Matthias Franz (dvipdfmx/dvipdfm).] [-author?Jens Elkner (2015 ksh93 port).] [-license?Public Domain] [+NAME?'"${PROG}"' - thumbnails for dvi] [+DESCRIPTION?This script makes a first (fast) run with dvipdfm, then calls gs on the resulting pdf file to get the thumbnails and finally calls dvipdfm to produce the \advifile\a. \bNOTE\b that all \advipdfm_option\as, which should be passed as is to \bdvipdfm\b(1) need to be given AFTER the output \afile\a!] [h:help?Print this help and exit.] [H:Help?Show the synopsis for this script and exit.] [F:functions?Print a list of all functions available.] [T:trace]:[fnList?A comma separated list of functions of this script to trace (convinience for troubleshooting).] [+?] [o:output]:[file?Set the \bpdf\b output \afile\a to use.] [V:version?Print version info for this script and exit.] \n\n\advifile\a [\advipdfm_option\a]... ' X="${ print ${USAGE} ; }" PDFFILE= while getopts "${X}" OPT ; do case ${OPT} in h) showUsage ; exit 0 ;; T) if [[ ${OPTARG} == 'ALL' ]]; then typeset -ft ${ typeset +f ; } else typeset -ft ${OPTARG//,/ } fi ;; F) typeset +f && exit 0 ;; V) print "${PROG} version ${VERSION} by Thomas Esser and others." exit 0 ;; o) PDFFILE="${OPTARG}" ;; *) showUsage 1; exit 2 ;; esac done X=$((OPTIND-1)) shift $X && OPTIND=1 unset X doMain "$@"