#/!bin/bash # # You need java, a2ps and ghostscript installed to run this script. # # Before running the script, you need to compile the GenerateGroups.java program # using a command like: javac GenerateGroups.java # # I have run this myself on Windows using cygwin, but any standard linux-like environment will probably do. function make_ps() { PAPER="$1" OUTPUT="$2" TITLE="$3" shift 3 java GenerateGroups --colums:80 $@ | \ a2ps --medium=$PAPER --output=$OUTPUT --no-header --left-footer="http://www.epust.dk/groups" --footer="%D{%F}" --right-footer="$TITLE" } function merge_to_pdf() { PAPER=$1 OUTPUT=$2 shift 2 gs -dBATCH -dNOPAUSE -q -sPAPERSIZE=$PAPER -sDEVICE=pdfwrite -sOutputFile=$OUTPUT $@ } make_ps a4 tmp1.ps "8 - 28" --rows:66 --fraction:32 --mintotal:8 --maxtotal:28 make_ps a4 tmp2.ps "29 - 36" --rows:66 --fraction:31 --mintotal:29 --maxtotal:36 make_ps a4 tmp3.ps "37 - 44" --rows:66 --fraction:47 --mintotal:37 --maxtotal:44 make_ps a4 tmp4.ps "45 - 50" --rows:66 --fraction:52 --mintotal:45 --maxtotal:50 merge_to_pdf a4 "groups-a4.pdf" tmp1.ps tmp2.ps tmp3.ps tmp4.ps make_ps letter tmp1.ps "8 - 28" --rows:72 --fraction:0 --mintotal:8 --maxtotal:28 make_ps letter tmp2.ps "29 - 36" --rows:72 --fraction:0 --mintotal:29 --maxtotal:36 make_ps letter tmp3.ps "37 - 44" --rows:72 --fraction:43 --mintotal:37 --maxtotal:44 make_ps letter tmp4.ps "45 - 50" --rows:72 --fraction:48 --mintotal:45 --maxtotal:50 merge_to_pdf letter "groups-letter.pdf" tmp1.ps tmp2.ps tmp3.ps tmp4.ps