Automate PDF actions

applescriptautomatorpdf

To improve my paperless workflow, I'm looking to achieve the following, potentially using automator / applescript. I need to be able to run it using Hazel, or as a folder action (not run manually):

1) Split a multi-page scanned & OCR'ed PDF into it's constituent pages, each in an individual file. Each file must contain the image and associated text.

2) Append a single PDF page to an existing multi-page PDF.

I've got a kind of working solution to the first item – create an automator workflow using the action that splits a PDF into odd and even pages, repeated several times. In my case I repeated it 6 times which produces 64 pages in the end, although most of them are blank and can be trashed based on their size. This takes a while to run though, so I'd like to know if there is a more streamlined way of accomplishing this.

The second one I've got nothing approaching a solution so far.

Best Answer

The answer to your second question might lead you directly to a solution to the first.

You'll want a tool that edits PDF files to append docments (or conversely, split them up). I use PDFPen for the job, but there are others that do less but might meet your needs.

Here is an article on using Hazel to script PDFPen as well as documentation on how PDFPen is scriptable in general. There is a Pro version of the app for a higher cost, so you might see if you need the extra features, but the normal version seems to meet your needs well enough.

Many helpful PDFPen example scripts can be found after you install the software in your user library:

~/Library/Application Support/PDFpen/Scripts

Opening them in the AppleScript Editor is a great way to learn more.

Related Question