Files
linux-bin/pdfshrink

36 lines
746 B
Plaintext
Raw Permalink Normal View History

2019-02-05 19:30:40 -08:00
#!/bin/bash
2019-07-16 14:51:48 -07:00
if [ "$1" == "-h" ] ; then
echo "
2023-09-28 22:52:04 -04:00
pdfshrink - resize pdf to smaller size. Warning: if no second file name is provided, the default behavior is to overwrite the original pdf
Usage: pdfshrink infile.pdf
pdfshrink infile outfile.pdf
Dependencies:
ps2pdf from Ghostscript
mktemp from GNU Coreutils
2019-07-16 14:51:48 -07:00
"
exit 0
fi
set -e
2019-02-05 19:30:40 -08:00
#Setup defaults
fn=$1
fn2=$2
2020-02-13 12:11:29 -08:00
2019-02-05 19:30:40 -08:00
set -e #exit if an error
#decide whether to use a provided new file name or too write over the original filename
if [ -z "$fn2" ]; then
#clean up
tmpName=$(mktemp $fn.XXXXXXX)
ps2pdf $fn $tmpName
#echo $tmpName
rm $fn
mv $tmpName $fn
chmod u=rw,go=r $fn
else
ps2pdf $fn $fn2
fi