Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
java -cp /opt/Multivalent.jar tool.pdf.Compress /tmp/5dd69f32-b97b-4f43-9bfa-f182e972f6ef.pdf
#!/bin/bash
file=$1
pages="`pdftk $file dump_data | grep NumberOfPages | cut -d : -f2`"
halfpages="`echo -n $(( $pages / 2 ))`"
width="$(pdfinfo $file | grep "Page size" | cut -d ':' -f2 | cut -d 'p' -f1 | cut -d 'x' -f1 | xargs)"
height="$(pdfinfo $file | grep "Page size" | cut -d ':' -f2 | cut -d 'p' -f1 | cut -d 'x' -f2 | xargs)"
doubleheight="$(echo $height*2 | bc)"
doublewidth="$(echo $width*2 | bc)"
sequence="`for ((x=$pages, y=1;x>=$halfpages, y<=$halfpages;x--, y++)); do echo "$x $y "; done | awk 'NR %2==1 {print $1, $2 } NR % 2==0 { print $2, $1, $2, $1 }' | xargs | tr " " ","`"
java -cp "/opt/Multivalent.jar" tool.pdf.Impose -verbose -dim 2x1 -paper "$doublewidth"x"$height"pt -layout "1,2" $file
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment