Looking for a way to automatically 'de-skew' a PDF via a script

Hey All, long time listener, first time caller!

I have a small Brother desktop scanner which works well for my limited needs. It, however, has an occasional tendency to skew the pages when scanning. PDFPen does a good job of correcting the skew but I don’t want to have to manually open it up each time I scan something.

I was hoping PDFPen’s applescript dictionary would allow me to script it but alas that functionality isn’t exposed.

Is anyone aware of an app / utility /scripting library which offers this capability that I can check out?


You could use your favourite tool (sips, ImageMagick, Automator, etc.) to split a PDF to images. Then straighten your images, using deskew, and convert them back to a single PDF using your preferred conversion tool again.

Hi @dexagram and welcome to the Automators forum!

There is a great free command line utility called OCRmyPDF that offers de-skew, rotate pages, OCR and many other pipeline functions when processing a PDF. Have a read of this part of it’s documentation.

I implement OCRmyPDF in my Paperless workflow (ala @MacSparky) using Hazel and it’s scripting abilities. I have set up simple one-time workflows in Hazel that are triggered by a tag and then apply a certain PDF-taming script to that file. For instance, I have set up Hazel rules to OCR, compress, de-skew and correct page rotation of PDFs, all based on tags as triggers. This allows case-by-case clean up of PDFs. See the MPU post below for an OCR-compress pipeline. In retrospect, I could have used OCRmyPDF for both of these actions. The rabbit hole is very deep when it comes to processing images and PDFs!

Thanks @sylumer and @scott.dellar. I will check out both options and reply back with with my workflow.