Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for an offline scriptable tool that makes an existing PDF file searchable by running OCR on it, replacing the original non-searchable file with the searchable version, and can run unattended.

E.g., - does exactly what I need, but it's GUI only - not scriptable.

I am aware that Evernote makes PDF files searchable, but they remain searchable only when within Evernote.

I am not looking for perfect OCR, even a moderately acceptable OCR is fine, but I would prefer a small utility rather than a bulky software package.

(I am aware of a similar, but different question on AD: Looking for Software to Scan or Convert to Searchable and Signable PDF - however, I don't need to sign or fill PDFs, and my requirement is that the solution is scriptable)


1) Several utilities allow structured text extraction, however in order to be extracted, the text must be there; I am mainly referring to PDFs that are wrapped bitmaps, as is the case with plain PDFs generated by scanners.

2) I am not necessarily looking for a free solution, and I would be more than happy to pay for a good utility that just does what I need, but I am not looking for bulky applications with a million features that include an OCR feature but whose cost does not justify buying them just for the OCR functionality.

3) As stated above, I am not looking for perfect OCR, just a moderately acceptable OCR. Unfortunately, in my experience, tesseract is really below that threshold. I define "moderately acceptable" an OCR that can, say, OCR an utility bill so that at least the account number (customer number) is recognized correctly.

EDIT: "scriptable" or "automatable", that is, able to be triggered automatically and run unattended without human input whatsoever.

share|improve this question
...don't know how hard it would be to do but Tesseract OCR often mentioned and OCR in Unix.SE. – hhh Mar 4 '13 at 18:12
There is a similar question here, does the answer fit your requirements? – patrix Mar 4 '13 at 18:33
You mention OCR. Do your requirements include handling images within PDF, or scanned PDF files? For files that have text within them as simple postscript, then a PDF to text converter like "PDF2Text Pilot" might work for you. – Tim B Mar 5 '13 at 3:16
@patrix I was looking for a smaller utility, not necessarily free but in a different price range. Still, it's a possible solution, thank you. – magma Mar 5 '13 at 5:02
@TimothyButler unfortunately I'm dealing with scanned PDFs (images). But, nice hint, thank you. – magma Mar 5 '13 at 5:04
up vote 4 down vote accepted

It's not entirely clear to me what your requirements are for being able to "script" this from the "command line".

If you are talking about automation, then that is possible with any number of utilities.

ABBYY FineReader Express + Keyboard Maestro + Hazel

I use ABBYY FineReader Express + Keyboard Maestro + Hazel like so:

  1. Hazel monitors a given folder for any new PDFs

  2. if a PDF is found, it is opened in "ABBYY FineReader Express"

  3. Keyboard Maestro then automates the process of turning the PDF into a Searchable PDF (OCR) and saves the file to a different directory.

Now, if you don't own Hazel and Keyboard Maestro already, your initial costs are going to rise pretty quickly (although I depend on both so much I consider them a bargain).

PDFPen + AppleScript + Folder Actions

You could do something similar with PDFPen (or PDFPenPro) and folder actions and AppleScript. See for one example.

Marco Arment did a survey of OCR apps for Mac and found that PDFPen had great results and was easy to automate.

A google search for "PDFpen applescript OCR" will turn up a number of alternatives.

share|improve this answer
good answer TJ. Hazel is amazing, I own it and I enjoy using it immensely. I don't currently own abbyy/keyboard maestro, but Hazel + PDFPen is an amazing combo. Overall, while all answers here are generally very good, and serve slightly different audiences, I think that Hazel+PDFPen is a good fit for the original problem. Accepted. – magma May 10 '13 at 12:10

What you want is Tesseract OCR. It's an open source OCR that is maintained by Google and supports a variety of platforms. It also has a native command line interface. It's exactly what you're looking for and available from the Mac ports project as well as homebrew.

Project Home:

How to install on OS X:

Usage Example: tesseract -l eng input.pdf output

share|improve this answer
Nice project. In my tests, recognition was poor, but I'm sure that depends on my inability to fine-tune it. I was looking for a lazier solution, but this might be a fine choice especially if you want more control and can dedicate time to it. – magma Oct 7 '15 at 17:48

Disclaimer: NOT AN OCR SOLUTION (but this answer is still useful to extract text from pdf)

There is an Apache Software Foundation project called Apache Tika:

A toolkit detects and extracts metadata and structured text content from various documents using existing parser libraries

They support PDF text extraction using PDFBox:

allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents. Apache PDFBox also includes several command line utilities

And they recently also added support for OCR (via Tesserac)

For a text based solution, PDFBox makes very simple to extract text from a PDF:

It also has some other nice options that you can see in ExtractText docs.

share|improve this answer
Definitely a nice option for extracting text, but there's no OCR capability that I can see. – magma Mar 11 '13 at 1:59
@magma OCR means "optical character recognition", there is definitely "OCR capability". Now you need to clarify: is your problem to extract text from poor-resolution image such as generated with VGA cam, poor scanner or distant picture? Then your problem is different and requires physical consideration of things such as super-resolution. Please, ask more specific and shorter questions so they can be answered. I suggest you to simplify this question to one feature you want. If you want something more, ask a new question. – hhh Mar 11 '13 at 4:06
@hhh, one thing is extracting text from a binary file (such as a PDF) so that it is usable and readable, by parsing the binary format. there is nothing optical about it. the text is already there, these utilities just extract it so that it's easy on your eyes, so to speak. optical character recognition is different in that it tries to recognize patterns of pixels in a bitmap and make enough sense of them that it can produce a corresponding text fragment. – magma Mar 15 '13 at 22:47
This does not answer the original question. AFAICT, pdfbox-app does not do OCR. – Feuermurmel Jan 31 at 11:47

I would recommend DEVONThink Pro Office. It is an excellent application and has very good AppleScript support. Alas only the 'Pro Office' version has the OCR capability - so you'll have to shell out £100 ($150).

It would be overkill if you're only using it for scripted OCR - but it's a very good app.

[edit] - ah just re-read your post - it would definitely be overkill!

If you just want OCR from the shell, you could try talking to ABBY whose engine DEVON licences:

share|improve this answer
Although the DEVONThink Pro Office in OS X is an overkill, it is interesting. If the developers designed it over OS X and iOS, it may though work (keeping the UI more simple) -- do you know anything like that? Cool idea though -- so the Pro version automatically adds the OCR layer to all kind of things such as screenshots and PDFs? And user can somehow "script" it? – hhh Mar 5 '13 at 13:31
Yes - the app has a good AppleScript Dictionary, which amongst other things, allows you to convert images stored in the app into searchable PDFs. – Diggory Mar 5 '13 at 14:01
Suppose I take pictures with iPhone or screenshots with OS X and put them to a folder ProjectA, does the DEVONThink add the OCR layer automatically to them even without specifying the language? Suppose you put them to a DropBox and then make DEVONThink in OSX to check the folder automatically, you could work with it over OS X and iOS then? It is a fascinating concept if done well... +1 – hhh Mar 6 '13 at 2:50
In a way, it sounds like EverNote where EverNote adds the OCR but not allowing its exporting like that. Is it possible to export your projects from this software with the OCR? If not, some very simple OCR lib and then some linguistic analysis lib may work the best. Perhaps the other is ABBY, I don't know yet. – hhh Mar 6 '13 at 2:57
It can recognise in several languages: – Diggory Mar 6 '13 at 8:56

You can make your existing PDF searchable by converting it into text file. You need for that at least Imagemagick, Ghostscript (for PDF conversion) and Tesseract OCR tool.

Some command-line example:

$ wget
$ convert -density 300 -depth 8 test.pdf test.png
$ tesseract test*.png test.txt
$ grep -i --color=auto the test*.txt
**The** details as told by surviving crew members, to **the** German publication Spiegel and published on ABC's

This can be extended further to your needs.

To install required tools, on OSX you may install it via Homebrew:

brew install imagemagick jpeg libpng ghostscript tesseract

On Linux use apt-get or yum instead of brew.

For more OCR tools, check: OCR on Linux systems


share|improve this answer

Stackoverflow has related questions under PDF-parsing covering things such as PDFBox and Apache's TIKA that the PDFBox uses. The ruby code below extracts writing from PDF. You need to have good enough resolution for this type of codes to work robustly. So get a good enough scanner with large resolution and then see if some of the softwares work.



SO threads






I am not sure whether I understood your problem now. You want to add OCR layer to different kinds of material such as random photos, screenshots, PDFs without OCR layer and so on? I don't know the solution but I am sure someone knows so asked a specific question how to do it with Automator and some OCR software:

Automator-script with an OCR-software to automatically add OCR to material?

share|improve this answer
Again: I am not looking to parse or extract text that is already there. I am looking to recognize text (OCR) in PDF file that are essentially images, bitmaps; they do not originally contain any text. – magma Mar 11 '13 at 2:00
@magma please, see my update. You want to automate the addition of OCR layer so you can search over different kinds of documents even without "searchable text"? If you could do this, you could search over all documents in Finder -- you understand? I am surprised if Apple does not do this in coming upgrades... – hhh Mar 11 '13 at 4:31
as stated in my question, yes. – magma Mar 15 '13 at 22:48

For this type of self-directed application, I'm a big fan of Hazel.

It makes it extremely easy to script actions without needing to learn a more command line oriented tool like perl or python and paired with the OCR engine of your choice (mine is currently PDF Pen Pro) you should have no problems getting your files processed with minimal fuss.

Both of these are paid software, but the utility of both far extends past this one case. In my situation, with the labor involved in digitizing my past scanned records (and ongoing paper), the price of these far outweighs the time I would have spend programming this elsewhere and now that I own both tools, I can do many other tasks with them.

share|improve this answer

PDFScannerApp does have an unofficial scripting support. Contact the author for the Automator action.

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

I use Adobe acrobat to OCR in batch. My duplex scanner can OCR after scanning but the OCR technology in acrobat is more accurate in my opinion. I just point to there folder that has no OCR then acrobat re saves the PDF as a searchable PDF now including a text layer. If I wanted to OCR via command line, I don't know of a way but I can automate the GUI end by using Autohotkey. Not as reliable nor fast as command line, but it does the job after you set up a workflow action to minimize the GUI interaction.

For Mac, apple script does what Autohotkey does on the PC although I haven't tried on my Mac yet.

Auto hot key comes with a recorder so most of the script writing is dinner for you with a littler bit of editing for refinement and perhaps looping if you want that.

I've been experimenting OCRing images but haven't automated the process fully yet through acrobat. Command line is ideal but haven't found a quality OCR engine that exceeds acrobat so I stick with acrobat for now.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.