#!/bin/bash # # Syntax: dvi2pdf [-s] [-n] [-p] [-l] [-t papersize] [-h] # [-d dir1:dir2:...] filename [...] # # Purpose: Transforms .dvi files into .pdf files using dvips with the # option -Ppdf -G0 and ps2pdf. # Use the -s flag to reduce the intermediate output printed to the # screen while running the script. # Use the -n flag to prevent compression of images (note: this # will in general increase the size of the file). # Use the -p flag to select prepress option (note: this # will in general increase the size of the file - can also help # in case you get font embedding warnings from pdf checkers). # Use the -l flag to select letter paper. # Use the -t flag to specify the paper format (currently recognized # formats are a4 (default), letter, a0, and other ghostscript # formats). Is it also possible to specify the paper format none # (required e.g. for beamer-based presentations). # Use the -d flag to specify extra directories to be added to # TEXINPUTS. # The -h flag shows the help info for this command. # # See also: dvips # # Note: You may have to include a line like # alias dvi2pdf=~/your_bin_dir/dvi2pdf # in your login files (e.g., .bashrc) in order to be able to use # this command. # Created: Mar 3, 2000 by Bart De Schutter # Last revised: Mar 22, 2012 by Bart De Schutter # # See http://www.deschutter.info/util/scripts.html for the latest version of # this script. # Status: public # Category: pdf, latex dvips_option="" pdf_option="-dCompatibilityLevel=1.4 -dMAxSubsetPct=100 -dSubsetFonts=true" pdf_option="$pdf_option -dEmbedAllFonts=true" ## -dColorImageResolution=600 pdf_option="-dEncodeColorImages=false" paper_size="a4" extra_dirs="" # # Options taken from www.paperplaza.net # while getopts :hsnplt:d: option do case "$option" in h) sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1;; s) dvips_option="$dvips_option -q";; l) paper_size="letter";; t) paper_size=$OPTARG;; n) pdf_option="$pdf_option -dAutoFilterColorImages=false \ -dColorImageFilter=/FlateEncode \ -dGrayImageFilter=/FlateEncode -dAutoFilterGrayImages=false \ -dMonoImageFilter=/FlateEncode";; p) pdf_option="$pdf_option -dPDFSETTINGS=/prepress";; d) extra_dirs=${OPTARG};; :) echo >&2 echo >&2 "Option -$OPTARG requires an argument." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 echo >&2 exit 1;; \?) echo >&2 echo >&2 "Unknown option: $OPTARG" echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1;; esac done shift $(($OPTIND-1)) if [ -n "${extra_dirs}" ] then TEXINPUTS="$TEXINPUTS${extra_dirs}:" fi if [[ "$paper_size" != "none" ]] then dvips_option="$dvips_option -t$paper_size" pdf_option="$pdf_option -sPAPERSIZE=$paper_size" fi if [ $# -eq 0 ]; then echo >&2 echo >&2 "ERROR: ${0##*/} requires at least 1 input argument." echo >&2 sed '/^$/q;/^#!/d;s/^# //;s/^#//' $0 >&2 exit 1 fi for fname in "$@" do \dvips $dvips_option -Ppdf -G0 "${fname%.dvi}.dvi" -o - | ps2pdf $pdf_option - "${fname%.dvi}.pdf" # -dEncodeColorImages=false done