OCR is the automated process of turning images into text.
This package contains open-source tools to help recreate searchable databases.
I use Poppler to convert PDFs to images, then I use Tesseract to convert images to text.
If you're not using a PDF, skip to the section on images.
-
Download the PDF you want to run OCR on
-
Convert the PDF to a series of images (one per PDF page):
pdftoppm -png input.pdf output_prefix
This command does not print progress, see enhancements for a version of this command that does print progress
-
Convert the images to a series of plaintext files:
find /path/to/images -name "*.png" -exec sh -c 'tesseract "$1" "$1.out" && echo "Done: $1"' _ {} \;
For progress when converting the PDF to a series of images, consider a loop:
n=$(pdfinfo input.pdf | grep Pages | awk '{print $2}')
for i in $(seq 1 $n); do
pdftoppm -png -f $i -l $i input.pdf page
echo "Converted page $i of $n"
done