2013-03-03 11:19:50 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if [ $# -lt 1 ] || [ $# -gt 2 ] || [ "$1" = "-h" ]; then
|
|
|
|
cat <<EOF
|
|
|
|
Usage: ${0##*/} PDFFILE [DESTFILE]
|
|
|
|
|
|
|
|
WARNING: use this function with caution. It may drastically improve compression
|
|
|
|
of some PDF files, but in some case, the output filesize will be greater! You
|
2013-06-25 22:56:10 +02:00
|
|
|
should not use it over PDF files embedding raster graphics as well.
|
2013-03-03 11:19:50 +01:00
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$1" ]; then
|
2013-06-25 22:56:10 +02:00
|
|
|
echo "$1 is not a valid file."
|
2013-03-03 11:19:50 +01:00
|
|
|
fi
|
|
|
|
INPUTFILE="$1"
|
|
|
|
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="${INPUTFILE%%.*}-COMPRESSED.pdf" "${INPUTFILE}"
|
|
|
|
rm -rf "${INPUTFILE}"
|
|
|
|
mv "${INPUTFILE%%.*}-COMPRESSED.pdf" "${INPUTFILE}"
|
|
|
|
else
|
2013-06-25 22:56:10 +02:00
|
|
|
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$2" "${INPUTFILE}"
|
2013-03-03 11:19:50 +01:00
|
|
|
fi
|