#!/bin/bash

# Job specific setting
filter=pbm2eps9
ghostscript=gs
hmul=1
hdiv=1
vmul=1
vdiv=1
hquality=3
vquality=3
pageoffset=0
headmask=0xff
# Headmask is a number between 0 and 255 inclusive. Bit of weight 128 denotes top pin
# on the printer head and bit with weight 1 denotes bottom pin on the printer head.
# Top is the one that prints near the top edge of the paper and bottom that prints
# nearer the bottom edge of the paper. Top edge is the edge of the paper you put up
# when you read the paper. If the bit is set it means the pin works. If the bit is 0
# it means the pin is not working. If the pin is specified by the user as non-working,
# the pbm2eps9 will not use it so that partially broken pins will not make smudges
# on the paper.

# Printer-specific setting 
hdpi=60
vdpi=72

case $hquality in
1) ;;
2) hmul=`expr $hmul '*' 2`;;
3) hmul=`expr $hmul '*' 2`;;
4) hmul=`expr $hmul '*' 4`;;
esac

case $vquality in
1) ;;
2) vmul=`expr $vmul '*' 3`
   vdiv=`expr $vdiv '*' 2`;;
3) vmul=`expr $vmul '*' 3`;;
esac

hdpi=`expr $hdpi '*' $hmul / $hdiv`
vdpi=`expr $vdpi '*' $vmul / $vdiv`

$ghostscript -q -r"$hdpi"x$vdpi -dNOPAUSE -dBATCH -sDEVICE=pbmraw -sOutputFile=- - | $filter $hquality $vquality $headmask

