From: Dan White Date: Fri, 6 Jun 2014 17:00:17 +0000 (-0500) Subject: bugfix interleaving X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=b7704deadb9cc993c80824280134548e5841cb9a;p=pubbin.git bugfix interleaving --- diff --git a/interleave.sh b/interleave.sh index e87b5f6..bc0f14b 100755 --- a/interleave.sh +++ b/interleave.sh @@ -28,7 +28,9 @@ while [ "$1" != "" ]; do exit 1 else infiles[$nfiles]=$1 - npages[$nfiles]=$(pdftk $1 dump_data | tail -n1 | awk '{print $2}') + #npages[$nfiles]=$(pdftk $1 dump_data | tail -n1 | awk '{print $2}') + npages[$nfiles]=$(pdftk $1 dump_data | grep NumberOfPages | awk '{print $2}') + echo ${npages[*]} [[ npages[$nfiles] -gt $maxpages ]] && maxpages=${npages[$nfiles]} let "nfiles=nfiles+1" if [[ $nfiles -gt 26 ]]; then @@ -51,7 +53,7 @@ fi # # there are nfiles circular buffers of pages of varying lengths, the number of # output pages is maxpages*nfiles. -for i in $(seq 1 $maxpages); do +for i in $(seq 0 $(($maxpages -1))); do [[ $VERBOSE == 1 ]] && echo "page $i" #assign each file a letter for referencing with pdftk pre="" @@ -62,11 +64,18 @@ for i in $(seq 1 $maxpages); do pre="$pre ${letters[$fnum]}=${infiles[$fnum]}" post="$post ${letters[$fnum]}$((i % npages[$fnum] +1))" done - pdftk $pre cat $post output $outfile-p$i.pdf + ii=$(printf "%04i" $i) + echo $pre + echo $post + echo $ii + echo + pdftk $pre cat $post output $outfile-p$ii.pdf done #cat all the aggregations together into the final page stream echo "putting all together" -pdftk $outfile-p*.pdf cat output $outfile +ofiles=$(ls -1 $outfile-p*.pdf | sort) +echo $ofiles +pdftk $(ls -1 $outfile-p*.pdf | sort) cat output $outfile rm -f $outfile-p*.pdf