#!/bin/bash

filter='./pbm2png'
ghostscript='gs'
basename='letters'
titlestring='Letters generated for Links'
bottom=''
pageoffset='0'

PATH=$PATH:./
hdpi=`expr $hundred_dpi '*' 17 '/' 100`
vdpi=`expr $hundred_dpi '*' 15 '/' 100`
start=$2
if [ "$start" = "" ]; then
 start=0
fi
start1=`expr $start + 1`

pname="/tmp/.pdf2html_pipe_$$"
function delete () { rm -f $pname; }
trap delete SIGINT

rm -f $pname
mkfifo $pname
$ghostscript -q -dFirstPage=$start1 -dNOPAUSE -dBATCH -sDEVICE=pbmraw -sPAPERSIZE=a4 -sOutputFile="$pname" -r"$hdpi"x"$vdpi" $1 &
$filter "$hundred_dpi" "$basename" "$titlestring" "$bottom" "$pageoffset" "$pname" $start
rm -f $pname

