Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BASH script to check PDF's are ocr'd

Tags:

linux

bash

pdf

xpdf

Don't know where to start on this really

I have a linux server with over 8000 PDf's and need to know which PDF's have been ocr'd and which one's haven't.

Was thinking some sort of script calling XPDF to check the pdf but to be honest not sure if this is possible

Thanks in advance for any help

like image 898
Grimlockz Avatar asked Dec 09 '25 19:12

Grimlockz


1 Answers

Make sure you have a commandline tool pdffonts installed. (There are two versions of this: one ships as part of the xpdf-utils, the other as part of the poppler-utils.)

All PDFs which consist of scanned pages only will not have any fonts used (neither embedded ones, nor un-embedded ones).

The commandline

pdffonts /path/to/scanned.pdf

will then not show any font information for that file.

This may already be enough for you to separate your files into two different sets.

If you have PDFs which have a mix of scanned pages and "normal" pages (or sanned-and-ocr'ed pages) then you'll have to extend and refine the above simplistic approach. See man pdffonts or pdffonts --help for more info.

like image 183
Kurt Pfeifle Avatar answered Dec 12 '25 17:12

Kurt Pfeifle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!