CaseLeaf

Handbook / The `ocr` command

The ocr command

A box of scanned correspondence arrives and none of it can be searched.

Recognises the text on any sheet that has none. A scanned document is a picture of words, and until this has run nothing can search it, quote it, read it aloud or check it. It is the first thing to do to anything that arrived from a scanner.

How you run it

caseleaf ocr report.pdf

caseleaf ocr report.pdf --again --pages 3,5-7

What each part means

In full, every part it will take:

caseleaf ocr <file> [--again] [--pages 3,5-7]
part what it is for
<file> The PDF to work on, as a path: report.pdf beside you, or the full path to it. This one is rewritten where it stands when there is anything to recognise. There is no --to for a copy, so make one first if the original matters. A document whose sheets all have working text already is left exactly as it was.
--again Recognise every selected page even though it already has text. Use it for a page whose old machine-read layer is wrong, most often because it was turned since. Off by default: a page with working text is left exactly as it was. (optional)
--pages Which sheets, as numbers or ranges separated by commas, so 1,3,5-7 is five sheets. Every command reads that spelling the same way, and a number the document does not have is refused rather than skipped.

Runs in place; there is no --to for a separate copy, so the original file is rewritten. A page that already has working text is skipped and nothing is written, so running this twice does nothing the second time. --again replaces a stale layer rather than adding to it.

What comes back

Asked of a short sample document, it answers as below. The sample has eight sheets, a highlight and a note left by a reviewer, a web link, a small table, two pictures and one form field already filled in.

{
  "pages" : 0,
  "written" : false
}

The same thing from AppleScript

Everything above can be asked for from a script instead. There is one AppleScript command, perform: on names the document, and options takes the rest exactly as you would type it.

tell application "CaseLeaf"
    perform "ocr" on "/path/to/report.pdf"
end tell

tell application "CaseLeaf"
    perform "ocr" on "/path/to/report.pdf" ¬
        options "--again --pages 3,5-7"
end tell

All the commands · Asking from a script · Contents