blob: 7f4a9accc5085277d27c97aec20b82230a9b0877 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/bash
# tmp dir
DIR="$(mktemp -dtp ${TMPDIR-/var/tmp} fbgs-XXXXXX)"
test -d "$DIR" || exit 1
trap "rm -rf $DIR" EXIT
# parse options
fbiopts=""
gsopts=""
passwd=""
device="tiffpack"
opt=1
while test "$opt" = "1"; do
case "$1" in
-l) gsopts="$gsopts -r100x100"
shift
;;
-xl) gsopts="$gsopts -r120x120"
shift
;;
-xxl) gsopts="$gsopts -r150x150"
shift
;;
-q | -a | --fitwidth)
fbiopts="$fbiopts $1"
shift
;;
-d | -m | -t | -g | -f)
fbiopts="$fbiopts $1 $2"
shift; shift
;;
-p) password="$2"
shift; shift
;;
-h) echo fixme: help text
exit 1
;;
-c) device="png16m"
shift
;;
-*) echo "unknown option: $1"
exit 1
;;
*) opt=0
;;
esac
done
# run ghostscript
echo
echo "### rendering pages, please wait ... ###"
echo
gs -dSAVER -dNOPAUSE -dBATCH \
-sPDFPassword="$password" \
-sDEVICE=${device} -sOutputFile=$DIR/ps%03d.tiff \
$gsopts \
"$1"
# tell the user we are done :-)
echo -ne "\\007"
# sanity check
pages=`ls $DIR/ps*.tiff 2>/dev/null | wc -l`
if test "$pages" -eq "0"; then
echo
echo "Oops: ghostscript wrote no pages?"
echo
exit 1
fi
# show pages
fbi $fbiopts -P $DIR/ps*.tiff
|