Automatically OCRing Documents with Hazel and PDFPen Pro

I used AppleScript to script the UI in Acrobat X in order to OCR a file.

tell application "Adobe Acrobat Pro"
activate
set theFile to "Macintosh HD:Users:Jim:Documents:img0005.pdf"
open theFile as alias
delay 2
activate
tell application "System Events"
	tell application process "Acrobat"
		-- run action to OCR
		click menu item "OCR_file" of menu 1 of menu item "Action Wizard" of menu 1 of menu bar item "File" of menu bar 1
		delay
		-- perform the OCR
		click button "Next" of window 1
		
		set OCRdone to false
		repeat while OCRdone is false
			try
				set OCRdone to true
				click button "Close" of window 1 -- will create error unless OCR is done
			on error
				set OCRdone to false
			end try
		end repeat
	end tell
	keystroke "w" using command down
end tell
quit
end tell
6 Likes