2022-11-14 10:00:29 +01:00
|
|
|
#!/bin/zsh
|
2021-05-07 13:26:19 +02:00
|
|
|
current="$(pwd)"
|
2022-11-14 10:00:29 +01:00
|
|
|
for file in $@; do
|
|
|
|
INPUTPDF=/tmp/file.pdf
|
|
|
|
cp -f "$file" $INPUTPDF
|
|
|
|
printf '\\documentclass[a4paper,final]{article}
|
|
|
|
\\usepackage{pdfpages}
|
|
|
|
\\usepackage{ifpdf,ifxetex,everyshi}
|
|
|
|
\\makeatletter
|
|
|
|
\\ifpdf
|
|
|
|
\\EveryShipout{\\ifodd\\c@page\\else\\pdfpageattr{/Rotate 180}\\fi}%%
|
|
|
|
\\fi
|
|
|
|
\\ifxetex
|
|
|
|
\\EveryShipout{\\ifodd\\c@page\\special{pdf: put @thispage << /Rotate 180 >>}%%
|
|
|
|
\\fi
|
|
|
|
}
|
|
|
|
\\fi
|
|
|
|
\\makeatother
|
|
|
|
\\begin{document}
|
|
|
|
\\includepdf[pages=-, nup=1x2, booklet=true, landscape]{%s}
|
|
|
|
\\end{document}' "$INPUTPDF" > /tmp/tmp$$.tex
|
|
|
|
cd /tmp || exit
|
|
|
|
pdflatex /tmp/tmp$$.tex
|
|
|
|
only_filename="$(echo "$file" | awk -F/ '{print $NF}')"
|
|
|
|
mv /tmp/tmp$$.pdf "$current/a5ona4_$only_filename"
|
|
|
|
cd "$current"
|
|
|
|
rm -f /tmp/tmp$$.log /tmp/tmp$$.log
|
|
|
|
done
|