impagina: Added documentation and a --help argument

removeproofs
Francesco Minnocci 2 years ago
parent e245525dd5
commit 57dd43cc46
Signed by: BachoSeven
GPG Key ID: 2BE4AB7FDAD828A4

@ -1,10 +1,28 @@
#!/bin/sh
usage() {
_name="$(basename "$0")"
cat << EOF
Utilizzo: ${_name} [nomePDF]
Esempi:
${_name} MeccanicaRazionale.pdf
Per bug contattare f.minnocci@studenti.unipi.it
I ringraziamenti per l'idea originale vanno a http://poisson.phc.dm.unipi.it/~dilillo
EOF
exit $1
}
main() {
# Initialize variables
input="$1"
inputMul4="/tmp/${input%.pdf}-Mul4.pdf"
outputImpaginato="${input%.pdf}-Impaginato.pdf"
input="$(realpath "$1")"
basename="$(basename "$1")"
inputMul4="/tmp/${basename%.pdf}-Mul4.pdf"
outputImpaginato="${basename%.pdf}-Impaginato.pdf"
empty="/tmp/empty.pdf"
echo "$input $basename $inputMul4 $outputImpaginato" > ~/log
n="$(pdftk "$input" dump_data | grep NumberOfPages | cut -d' ' -f2)"
# Add empty pages
@ -25,3 +43,17 @@ done
pdftk "$inputMul4" cat $range output "$outputImpaginato"
rm "$empty" "$inputMul4"
}
if [ -z "$1" ] ; then
printf "Non hai specificato nessun file...\n\n" && usage 1
else
case "$1" in
-h|--help)
usage 0 ;;
-*)
error "Opzione invalida: $1" ;;
*)
main "$@" ;;
esac
fi

Loading…
Cancel
Save