blob: ac725fadf4ed95735b222f4e1a4bec6b070428ed (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#!/bin/sh
#
# PostScript/pdf viewer for the linux framebuffer console
# (c) 1999-2012 Gerd Hoffmann <gerd@kraxel.org>
#
# 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="png16m"
opt=1
bell="off"
helptext="\
This program displays PostScript/pdf files using the linux framebuffer device.
It is a simple wrapper script for GhostScript and fbi.
Note: you might want try the new fbpdf instead.
usage: fbgs [fbgs options] [fbi options] file
-b --bell emit a beep when the document is ready
-h --help print this help text
-p --password <arg> a <password> passed to the PDF
-fp --firstpage <arg> begins on the <arg> page
-lp --lastpage <arg> stops on the <arg> page
-c --(no)color pages in color
-l pages rendered with 100 dpi
-xl pages rendered with 120 dpi
-xxl pages rendered with 150 dpi
-r --resolution <arg> choose resolution of <arg> dpi
Read the fbgs(1) and fbi(1) manpages for more details.
"
[ $# -ne 0 ] || set -- -h
while test "$opt" = "1"; do
case "$1" in
# fbgs options
-b | --bell)
bell="on"
shift
;;
-h | --help)
printf "$helptext"
exit 1
;;
-p | --password)
password="$2"
shift; shift
;;
-fp | --firstpage)
gsopts="$gsopts -dFirstPage=$2"
shift; shift
;;
-lp | --lastpage)
gsopts="$gsopts -dLastPage=$2"
shift; shift
;;
-c | --color)
device="png16m"
shift
;;
--nocolor)
device="tiffpack"
shift
;;
-l) gsopts="$gsopts -r100x100"
shift
;;
-xl) gsopts="$gsopts -r120x120"
shift
;;
-xxl) gsopts="$gsopts -r150x150"
shift
;;
-r | --resolution)
gsopts="$gsopts -r$2x$2"
shift; shift
;;
# fbi options without argument
-a | --autozoom | \
--autoup | --noautoup | \
--autodown | --noautodown | \
--fitwidth | --nofitwidth | \
--readahead | --noreadahead | \
-v | --verbose | --noverbose | \
-u | --random | --norandom | \
-1 | --once | --noonce)
fbiopts="$fbiopts $1"
shift
;;
# fbi options with one argument
-T | --vt | \
-s | --scroll | \
-t | --timeout | \
-g | --gamma | \
-f | --font | \
-d | --device | \
-m | --mode)
fbiopts="$fbiopts $1 $2"
shift; shift
;;
# others options
-*) echo "unknown option: $1"
exit 1
;;
*) opt=0
;;
esac
done
if [ ! -f "$1" ]; then
echo "fbgs: cannot stat '$1': No such file or directory"
exit 1
fi
# run ghostscript
echo
echo "### rendering pages, please wait ... ###"
echo
gs -dSAFER -dNOPAUSE -dBATCH \
-sPDFPassword="$password" \
-sDEVICE=${device} -sOutputFile=$DIR/ps%03d.tiff \
$gsopts \
"$1"
# tell the user we are done :-)
if test "$bell" = "on"; then
printf "\a"
fi
# 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
|