| 1 |
#!/bin/sh - |
| 2 |
do_opt=1 |
| 3 |
best=0 |
| 4 |
rot=0 |
| 5 |
a4=0 |
| 6 |
eps=0 |
| 7 |
usage="Usage: $0 [-no_opt] [-best] [-rot] [-a4] [-eps] in.ps [out.pdf]" |
| 8 |
|
| 9 |
case "x$1" in |
| 10 |
"x-no_opt") do_opt=0 ; shift ;; |
| 11 |
esac |
| 12 |
|
| 13 |
case "x$1" in |
| 14 |
"x-best") best=1 ; shift ;; |
| 15 |
esac |
| 16 |
|
| 17 |
case "x$1" in |
| 18 |
"x-rot") rot=1 ; shift ;; |
| 19 |
esac |
| 20 |
|
| 21 |
case "x$1" in |
| 22 |
"x-a4") a4=1 ; shift ;; |
| 23 |
esac |
| 24 |
|
| 25 |
case "x$1" in |
| 26 |
"x-eps") eps=1 ; shift ;; |
| 27 |
esac |
| 28 |
|
| 29 |
case $# in |
| 30 |
2) ifilename=$1 ; ofilename=$2 ;; |
| 31 |
1) ifilename=$1 |
| 32 |
if `echo $1 | grep -i '\.e*ps$' > /dev/null` |
| 33 |
then |
| 34 |
ofilename=`echo $1 | sed 's/\..*$/.pdf/'` |
| 35 |
else |
| 36 |
echo "$usage" 1>&2 |
| 37 |
exit 1 |
| 38 |
fi ;; |
| 39 |
*) echo "$usage" 1>&2 ; exit 1 ;; |
| 40 |
esac |
| 41 |
|
| 42 |
if [ $best == 1 ] |
| 43 |
then |
| 44 |
options="-dPDFSETTINGS=/prepress \ |
| 45 |
-r1200 \ |
| 46 |
-dMonoImageResolution=1200 \ |
| 47 |
-dGrayImageResolution=1200 \ |
| 48 |
-dColorImageResolution=1200 \ |
| 49 |
-dDownsampleMonoImages=false \ |
| 50 |
-dDownsampleGrayImages=false \ |
| 51 |
-dDownsampleColorImages=false \ |
| 52 |
-dAutoFilterMonoImages=false \ |
| 53 |
-dAutoFilterGrayImages=false \ |
| 54 |
-dAutoFilterColorImages=false \ |
| 55 |
-dMonoImageFilter=/FlateEncode \ |
| 56 |
-dGrayImageFilter=/FlateEncode \ |
| 57 |
-dColorImageFilter=/FlateEncode" |
| 58 |
else |
| 59 |
options="-dPDFSETTINGS=/prepress \ |
| 60 |
-r600 \ |
| 61 |
-dDownsampleMonoImages=true \ |
| 62 |
-dDownsampleGrayImages=true \ |
| 63 |
-dDownsampleColorImages=true \ |
| 64 |
-dMonoImageDownsampleThreshold=2.0 \ |
| 65 |
-dGrayImageDownsampleThreshold=1.5 \ |
| 66 |
-dColorImageDownsampleThreshold=1.5 \ |
| 67 |
-dMonoImageResolution=600 \ |
| 68 |
-dGrayImageResolution=600 \ |
| 69 |
-dColorImageResolution=600 \ |
| 70 |
-dAutoFilterMonoImages=false \ |
| 71 |
-dMonoImageFilter=/FlateEncode \ |
| 72 |
-dAutoFilterGrayImages=true \ |
| 73 |
-dAutoFilterColorImages=true" |
| 74 |
fi |
| 75 |
|
| 76 |
if [ $rot == 1 ] |
| 77 |
then |
| 78 |
options="$options -dAutoRotatePages=/PageByPage" |
| 79 |
fi |
| 80 |
|
| 81 |
if [ $eps == 1 ] |
| 82 |
then |
| 83 |
options="$options -dEPSCrop" |
| 84 |
fi |
| 85 |
|
| 86 |
set -x |
| 87 |
|
| 88 |
if [ $a4 == 1 ] |
| 89 |
then |
| 90 |
# Resize from A4 to letter size |
| 91 |
psresize -Pa4 -pletter "$ifilename" myps2pdf.temp.ps |
| 92 |
ifilename=myps2pdf.temp.ps |
| 93 |
fi |
| 94 |
|
| 95 |
gs -q -dSAFER -dNOPAUSE -dBATCH \ |
| 96 |
-sDEVICE=pdfwrite -sPAPERSIZE=letter -sOutputFile=myps2pdf.temp.pdf \ |
| 97 |
-dCompatibilityLevel=1.3 \ |
| 98 |
$options \ |
| 99 |
-dMaxSubsetPct=100 \ |
| 100 |
-dSubsetFonts=true \ |
| 101 |
-dEmbedAllFonts=true \ |
| 102 |
-dColorConversionStrategy=/LeaveColorUnchanged \ |
| 103 |
-dDoThumbnails=true \ |
| 104 |
-dPreserveEPSInfo=true \ |
| 105 |
-c .setpdfwrite -f "$ifilename" |
| 106 |
|
| 107 |
if [ $do_opt == 1 ] |
| 108 |
then |
| 109 |
pdfopt myps2pdf.temp.pdf $ofilename |
| 110 |
else |
| 111 |
mv myps2pdf.temp.pdf $ofilename |
| 112 |
fi |
| 113 |
rm -f myps2pdf.temp.pdf myps2pdf.temp.ps |