blob: 6e273ee5e89e95990794455c12879f3399d016c4 (
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
|
#!/bin/bash
# this script is part of the pdf-annotation LaTeX package by M. Palmer
# like all files in the package, it is covered by the LPPL.
# this assumes ghostscript is installed as 'gs - change as needed
ghostscript="gs"
script_name=`basename "$0"`
if [ -z $1 ]; then
echo "Usage: $script_name inputfile.pdf [quality [outputfile]]"
exit 1
fi
input_pdf=$1
# values for 'quality' argument:
#
# 'prepress' is highest quality
# 'printer' or 'default' are 300dpi, both quite good
# 'ebook' is 150 dpi; still reasonable on screen
# 'screen' is 72dpi - looks poor
if [ ! -f $input_pdf ]; then
echo "file $input_pdf not found"
exit 1
fi
# let quality default to 'default'
quality=${2-default}
if [ $quality = 'default' ]; then
suffix="shrunk"
else
suffix=$quality
fi
output_pdf=${3-${1%.pdf}-${suffix}}
output_pdf=${output_pdf%.pdf}.pdf
echo "converting $input_pdf to $output_pdf using quality '$quality'"
$ghostscript \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dHaveTransparency=true \
-dFastWebView=true \
-dPDFSETTINGS=/$quality \
-dEmbedAllFonts=true \
-dSubsetFonts=true \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-sOutputFile="$output_pdf" \
"$input_pdf"
chmod 644 "$output_pdf"
echo "done"
|