#!/bin/bash

if [ $# -gt 1 ]; then
    typescript="$1"
    shift;
else
    typescript="typescript";
fi

if [ -n "$1" ]; then
    if [ -e "$typescript" ]; then
        cleants "$typescript" |aha |xvfb-run -a -s "-screen 0, 1024x768x24" wkhtmltopdf --quiet --disable-smart-shrinking --minimum-font-size 33 --page-size Letter - - |pdfjam --quiet --landscape --nup 2x1 --frame true --outfile "$1.pdf";
        #cleants $typescript |aha |wkhtmltopdf --quiet --disable-smart-shrinking --minimum-font-size 33 --page-size Letter - - |pdfjam --quiet --landscape --nup 2x1 --frame true --outfile $1.pdf;
        echo "\"$typescript\" printed to \"$1.pdf\".";
    else
        echo "Cannot find typescript file ($typescript).  Please run your script first.";
    fi;
else
    echo "Please tell me the name of the PDF file to create.";
fi
