This is something I have to do from time to time especially around tax season as I tend to get scanned documents in PDF format which are just unnecessarily too big in size.
I like to keep important documents in smaller sizes as I keep them archived for a long a time and they add up. I want to be able to quickly download or upload them somewhere even with a slow internet connection.
I figured I'll write a blog post about it as I can never remember the command to use. Below is the Ghostscript command to do this. The ghostscript package is already installed by default on Ubuntu so it should just work:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_PDF_file.pdf input_PDF_file.pdf
The options in bold are the most important.
dPDFSETTINGS - The output quality (higher quality = bigger file size).
Valid values are:
- /prepress - Default setting, highest quality (300 dpi)
- /ebook - Medium quality (150 dpi)
- /screen - Lowest quality (72 dpi)
sOutputFile - The filename of the output file.
And the last argument of course is the input file.
I tend to go with the /ebook option which is plenty good for me. I actually just ran the command a few minutes ago and compressed a 5MB file to 710KB with the /ebook quality option.