Here is a bash script that reduces the size of a PDF file provided as an argument.

 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
#! /bin/bash
# PP 29/08/2011

# command line taken from:
# http://www.ubuntugeek.com/ubuntu-tiphowto-reduce-adobe-acrobat-file-size-from-command-line.html

# check an argument is provided
if [ $# -eq 0 ]
then
    echo "missing argument (PDF file)"
    exit
fi

# check the argument is an existing file
if [ ! -e $1 ]
then
    echo "argument $1 is not a file"
    exit
fi

input=$1
output=${input%pdf}reduced.pdf

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dUseCIEColor -sOutputFile=$output $input

# print file size
du -sh $input
du -sh $output

Comments

comments powered by Disqus