Auto reloading a PDF on OS X

Currently, I create presentations using rst2pdf and so I regularly have vim open side by side with the Preview app showing the rendered PDF.

I use a Makefile to create the PDF from the rst sources, so I just use :make in vim to rebuild the PDF file and then had to switch to Preview in order for it to reload the updated PDF file. Recently a friend wondered why the PDF viewer couldn't reload automatically. This was a very good point, so I looked into it.

It turns out that while you can control Preview via AppleScript, you can't make it reload a PDF without it taking focus. I didn't want that as then I have to switch back to vim.

Enter Skim

The solution is to use Skim, an open source PDF viewer for Mac.

This app has the ability to automatically detect changes to an open file and reload it. You can open Skim from the command line using:

Note that it doesn't work straight out of the box… Open Skim and set the Preferences => Sync => Check for file changes setting. It will then look for changes to the file on disk when running.

However… it brings up an annoying dialog when it detects a file change! There's a hidden preference to disable this, so run this from the command line:

And then it works as we'd hope.

Leave a Reply

Your email address will not be published. Required fields are marked *