Recommended technique to identify a PDF with no OCR layer in a script

It is what was suggested and used in scripts for a long time to differentiate between PDFs with and without OCR.

That is hard to imagine. How (and why?) would someone stop the OCR after the title? Or remove everything from the text layer after it? At least in my case (see below), since the PDFs are machine-generated, they either have a complete text layer or none at all.

That depends on what you want to do, I think. For example, I process incoming PDFs with a smart rule, which consists basically only of a script. Simply because smart rules can’t handle conditions.
In a script, I can write (symbolically)

if record has no text layer
  do OCR
end if

and then I handle the new (ie textlayer-ed) record just as any other that already has a text layer: get the text, scan it for different regular expressions, generate standardized names depending on these Res and move the records to the appropriate subgroups (again, depending on the content of the records). In one script, which is run by one smart rule. Doing that without a script, only with a smart rule, is not possible with a single rule. AFAIK.

There are lots of things one can do with smart rules, and I’m always surprised when @BLUEFROG pulls another trick out of his hat. But there are also things that can’t be done with them. Conditional processing is one of them.

1 Like

I have seen this behaviour (not “someone’s”, but the less than perfect OCR’s) as well. Computers are frustratingly non-binary in the real world.

Sean

Yup. The whole reason my setup is this way is because I got caught out several times with PDFs that seemed to have an OCR layer and didn’t, and when I troubleshooted the issue in here others had experienced the same and recommended changing the word count in my search to identify problematic files.

Number of words < 1…

Most likely the PDF was not OCRed at all but created with a poor or incomplete PDF layer instead. E.g. in my experience frequently PDFs created by servers (e.g. banking) or on other platforms or electronic magazines etc.

1 Like

The next release will add a new has text layer property.

6 Likes