#!/bin/bash # Dependencies: # apt-get install pdfjam tetex-bin pdftk # Duplex Off: # /usr/bin/lpr -P HAAS-110 -o Duplex=None # Duplex Flip on Long Edge: # /usr/bin/lpr -P HAAS-110 -o Duplex=DuplexNoTumble # /usr/bin/lpr -P HAAS-110 -o InputSlot=Tray2 -o Duplex=DuplexNoTumble # Duplex Flip on Short Edge: # /usr/bin/lpr -P HAAS-110 -o Duplex=DuplexTumble # /usr/bin/lpr -P HAAS-110 -o InputSlot=Tray2 -o Duplex=DuplexTumble # lpr -P HAAS-110 -o page-ranges=1-2 -o number-up=2 -o media=Letter -o scaling=95 -o Duplex=DuplexTumble *.pdf # http://wwwcascina.virgo.infn.it/lpoptions.html if [ ! -e $1 ]; then echo "File $1 does not exist." exit 1 fi if [ x$(echo $1 | sed -n '/\.pdf$/ p') == x ]; then echo "File $1 is not a valid PDF." exit 2 fi #INFILE=$1 INFILE=`echo $1|sed -e 's/\.pdf$//g'` if [ x$2 == x ]; then OUTFILE="$INFILE-2x1.pdf" else OUTFILE=$2 fi #TMPFILE="`mktemp`.pdf" #if [ -e $TMPFILE ]; then # echo "Could not allocate temporary file: \"$TMPFILE\"." # exit 3 #fi # if PDF is from JSTOR if grep -Uq "www.jstor.org/about/terms" $INFILE.pdf; then echo "processing JSTOR article" # drop first page (i.e., JSTOR) DROPFILE="$INFILE-drop.pdf" pdftk $INFILE.pdf cat 2-end output $DROPFILE # the cropfile will be the same name as DROPFILE with -crop appended before # the suffix CROPFILE="$INFILE-drop-crop.pdf" pdfcrop --margins '-30 -40 -25 -40' --clip $DROPFILE pdfnup --nup 2x1 --paper letterpaper --outfile $OUTFILE --frame false $CROPFILE rm $DROPFILE $CROPFILE else # the cropfile will be the same name as INFILE with -crop appended before # the suffix TMPFILE="$INFILE-crop.pdf" # 1bp = 1/72 inch => .125"=9bp # --margins " " # IEEE (auto-clipping failed due to scan) #pdfcrop --margins '-43 -32 -34 -15' --clip $INFILE.pdf # JSTOR (auto-clipping failed due to scan) #pdfcrop --margins '-30 -40 -25 -40' --clip $INFILE.pdf # Misc (auto-clip, includes JMLR) pdfcrop --margins '2 0 2 0' --clip $INFILE.pdf # Bruce Lindsay scan #pdfcrop --margins '-28 -23 -25 -24' --clip $INFILE $TMPFILE || exit 4 # old #pdfcrop --margins '9 5 9 5' --clip $INFILE $TMPFILE 1>/dev/null || exit 4 # --trim " " in points # for example: --trim '1.5in 2in 1.5in 1.5in' pdfnup --nup 2x1 --paper letterpaper --outfile $OUTFILE --frame false $TMPFILE rm -f $TMPFILE fi