I’m going to be honest. I don’t worry too much about PDF file size. Storage (both local and online) is relatively cheap. However, sometimes people will ask me how to reduce PDF file size, so it’s clearly a topic of interest.
There are many solutions out there, but over on the Asian Efficiency Dojo, user Andrew pointed me to this AskUbuntu Q&A thread and reported that he was having success with one of the tips. Since it’s been quite a while since I’ve gotten geeky here on DocumentSnap, I figure this is a good excuse.
A few notes before we get started:
- As I mentioned, this tip is extremely geeky and involves scripting and a command shell (aka the Terminal on macOS). If you’re not comfortable with that, you may want to give this one a pass and use something like Adobe Acrobat or macOS Preview.
- This tip uses a Unix tool called Ghostscript. I’ll be showing the tip on the Mac, and the page I linked to above is for Linux. There is a version of Ghostscript on Windows, but I am not sure if this tip will work with it.
Install Ghostscript
Chances are, your computer may not have Ghostscript installed (my Mac did not).
The easiest way to get Ghostscript on the Mac is to use Homebrew. If you don’t already have Homebrew, follow the instructions on the site.
Once you have Homebrew installed, install Ghostscript by going to Terminal and typing:
brew install ghostscript
Homebrew will do its magic, and you should be good to go.
Use Ghostscript to Reduce PDF File Size
In the AskUbuntu thread linked above, there are a number of suggestions. The one that Andrew recommended is this one.
I tried using screen for PDFSETTINGS, but the result looked awful. For me, ebook did the trick. There’s a tiny (to my eyes) reduction in quality, but for most of my scanned PDFs the file size was reduced quite a bit.
As a result, here’s the script that I’ve been using:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
In this example I’m using this scanned PDF, which is 1,501,178 bytes:
I ran the script in a Terminal window to compress it:
You can see that it reduced the 1.5 MB file to 565 KB:
Here’s a link to the file so you can take a look. You can see it’s a liiiiittle more blurry, but not too bad.
Automating Ghostscript With Hazel
The nice thing about using a script to reduce file size is that there is the potential for automation. Here’s a quick Hazel rule I used to watch a folder and automatically reduce the file size:
You can see that I embedded the script above, but made some tweaks to make it work with Hazel and output to a folder called Output. You can, of course, adjust that to go to any folder.
You don’t need Ghostscript to reduce PDF files, but it’s nice to know you can
As I said earlier, you don’t need to get this geeky to make PDFs smaller. You can scan at a reduced resolution, you can use a tool like Acrobat or PDFpen, or you can use other specialized tools for your operating system. Sometimes it’s fun to bust out the Terminal though, so that’s what I did (I have a sad definition of fun, I know).
Do you use a different method? Let us know in the comments how you do it.