Why reducing the file size of PDFs sometimes is neccessary

I often end up having PDF documents that are too large to send anywhere -- be it because I actively just don't want to send that 3 mb 2 page PDF or that the receiving system won't accept larger files than 2 mb (when sending in taxes receits for example).

The reason for those large PDFs often is, that a text based document got scanned in as a picture, so that the PDF document really consists of one large jpeg image per side.

What is it?

Now, the macOS Preview application has had so called Quartz Filters for ages, one of which is called Reduce File Size-- sounds promissing, doesn't it? Problem is, this filter is reducing those images so massively, that text will end up in a blur and something that you don't want to send neither...

How do I use them?

When working with Apple Preview, you can get to the filters by

  1. opening the Print Dialogue by choosing File > Export from the Menu Bar
  2. make sure that PDF is chosen in the Format dropdown menu
  3. beneath that, there is another dropdown menu called Quartz Filter
  4. open said dropdown menu and find Reduce File Size there
  5. choose the saving location and conclude by clicking on Save

The solution: creating your own filter

File Location(s)

The nice thing abount these filters is: they are just plist / xml files, and when you know what property to change, you can actually tweak the filter to produce the results that you like to have.

First of all, you need to know where those filters are located: you will find them in /System/Library/Filters. A good starting point obviously is just to copy one of those filters and tweak that copy. Copying into the same folder did work until macOS 10.11, but starting with macOS 10.12, neither the administrator nor the superuser have writing access to System/Library/Filters.

So, this seems to be a dead end -- but is it really?
No, it is not. There are several levels of Libraries being considered by Preview for Quartz Filters:

  • /System/Library
  • /Library
  • ~/Library

So, the easiest solution in my point of view is to copy the filter into the user's home folder. As there is no Filters folder in the home library though, one needs to create that manually first:

mkdir ~/Library/Filters

After that we can copy the filter -- I am taking the Reduce File Size filter for that:

cp /System/Library/Filters/Reduce\ File\ Size.qfilter ~/Library/Filters

Value to change

The plist / xml property to change is found here:

<key>ImageSizeMax</key>
<integer>512</integer>

The default value for this filter is 512 - changing this to 1024 or 2048 will result in much better, yet still small enough PDF files. So, after changing the value, saving the file and restarting Preview, the new Filter will be available.

Naming of the Filter

One thing to note though is, that now we have two entries of Reduce File Size in the Filter area of above described Export Dialogue. This is because the name of the filter displayed there is saved to the .qfilter-file as well, so renaming the file only won't be suffice. To do that, change the following plist / xml property:

<key>Name</key>
<string>Reduce File Size</string>

I chose to change that value to Reduce File Size - Better. Now, I can choose this filter to get a better, yet reduced PDF file, that still has a good enough quality.

Conclusion

I showed you a solution to copy and alter an existing Quartz Filter to be able to reduce PDF file sizes in a way that those PDFs are still readable by copying one of the existing filters and changing a few of its values.

Previous Post Next Post