This means you can convert scans or images of documents into searchable, editable PD files, and even adjust the quality of the resulting files.
If using a Linux-based operating system, you have more power with OCRmyPDF. We show here using Ubuntu Linux 18.04 how to install the latest version of OCRmyPDF and how to use it to turn scanned/grayscale pdfs into more functional files.
Installing the latest version of OCRmyPDF on Ubuntu 18.04 LTS
Install several system dependencies by firstly updating all repositories with the commands:
- $sudo apt-get -y update
- $sudo apt-get -y install \
- ghostscript \
- icc-profiles-free \
- liblept5 \
- libxml2 \
- pngquant \
- python3-cffi \
- python3-distutils \
- python3-pkg-resources \
- python3-reportlab \
- qpdf \
- tesseract-ocr \
- zlib1g
Some dependencies such as the JBIG2 encoder may be missing and pngquant may not be installed, hence you can install them separately (But, OCRmyPDF will still work fine without them).
Install JBIG2 encoder:
JBIG2 encoding is recommended for OCRmyPDF and is used to losslessly create smaller PDFs. If JBIG2 encoding is not available, lower quality encodings will be used.
Installation needs you to build a JBIG2 encoder from source:
- $git clone https://github.com/agl/jbig2enc
- cd jbig2enc
- ./autogen.sh
- ./configure && make
- [sudo] make install
Install pngquant:
- $sudo apt-get update -y
- $sudo apt-get install -y pngquant
We will need a newer version of pip available for Ubuntu 18.04 by the time of installation:
- $wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
Lastly, install the most recent OCRmyPDF for the local user and set the user’s PATH to check for the user’s Python packages:
- $export PATH=$HOME/.local/bin:$PATH
- $python3 -m pip install --user ocrmypdf
Usage:
You can then ocr your pdf (input.pdf) and get a very useful pdf (output.pdf) as follows:
- $ocrmypdf input.pdf output.pdf
If you cannot achieve this by using your local machine, you can ocr your pdf into something else by using the onlineocr tool