forked from Munter/RevyTeX
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git@github.com:dikurevy/RevyTeX
- Loading branch information
Showing
1 changed file
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
pdftk $1 cat 16 1 15S 2S 14 3 13S 4S 12 5 11S 6S 10 7 9S 8S output __temp__.pdf | ||
pdfnup __temp__.pdf --outfile $1.booklet.pdf | ||
rm __temp__.pdf | ||
pages=`pdftk $1 dump_data output | grep NumberOfPages | grep -oP "\d+"` | ||
pages=`echo "$pages + ((4 - ($pages % 4)) % 4)" | bc` | ||
args="" | ||
|
||
for (( i = 0; i <= $pages/2-1; i++ )) | ||
do | ||
s1=`expr $pages - $i` | ||
s2=`expr $i + 1` | ||
|
||
if (( i % 2 == 0)); then | ||
args="$args $s1 $s2" | ||
else | ||
args="$args ${s1}S ${s2}S" | ||
fi | ||
done | ||
|
||
pdftk $1 cat $args output - | pdfnup --outfile ${1}.booklet.pdf |