Skip to content

Instantly share code, notes, and snippets.

@pankaj28843
Created December 8, 2015 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pankaj28843/e6e8fc17ce080fe78cda to your computer and use it in GitHub Desktop.
Save pankaj28843/e6e8fc17ce080fe78cda to your computer and use it in GitHub Desktop.
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