PDF-Manipulation-Tools

Excellent Utilities: OCRmyPDF – add OCR text layer to scanned PDFs

This is a series highlighting best-of-breed utilities. We cover a wide range of utilities including tools that boost your productivity, help you manage your workflow, and lots more besides. There’s a complete list of the tools in this series in the Summary section.

Optical Character Recognition (OCR) is a visual recognition process that turns printed or written text into an electronic character-based file. This makes the document searchable and offers the ability to copy-paste its contents.

PDF is generally considered to be an excellent format for storing and exchanging scanned documents. Unfortunately, PDFs aren’t trivial to modify. OCRmyPDF makes it easy to apply image processing and OCR to existing PDFs. The program add an OCR text layer to scanned PDF files. It’s a command-line only affair.

Let’s get an important distinction out of the way. If you create a PDF document from an electronic source, there will already be an OCR layer applied. Native PDF files have an internal structure that can be read and interpreted. These “generated” PDF documents already contain characters that have an electronic character designation. The most popular office suite for Linux is LibreOffice. That suite automatically applies a text layer to documents exported to the PDF format. For this scenario, you don’t need OCRmyPDF.

PDF documents are also created by scanning a paper document into an electronic format. Typically, this is with a flatbed scanner. The scanner takes a “snapshot” of the paper document. This snapshot is turned into a PDF (or another format such as JPG and TIFF). This is a “scanned” PDF document which often won’t have an OCR layer. Want to add that text layer? Step forward OCRmyPDF.

Installation

Installation procedure will depend on the Linux distro you’re using. On my Arch based system, installation is trivial, as there’s a package in the Arch User Repository.

Installing the package pulls in a number of other programs including tesseract, img2pdf, pngquant, unpaper, and various Python packages.

You’ll also need a language pack.

$ sudo pacman -S tesseract-data-eng

I’m using the English language pack for Tesseract. But Tesseract supports most languages. Just install the relevant language pack(s) for your requirements. And there’s support for multilingual documents.

Next page: Page 2 – In Operation

Pages in this article:
Page 1 – Introduction / Installation
Page 2 – In Operation
Page 3 – Summary


Complete list of articles in this series:

Excellent Utilities
tmuxA terminal multiplexer that offers a massive boost to your workflow
lnavAdvanced log file viewer for the small-scale; great for troubleshooting
PaperworkDesigned to simplify the management of your paperwork
AbricotineMarkdown editor with inline preview functionality
mdlessFormatted and highlighted view of Markdown files
fkillKill processes quick and easy
TuskAn unofficial Evernote client with bags of potential
UlauncherSublime application launcher
McFlyNavigate through your bash shell history
LanguageToolStyle and grammar checker for 30+ languages
pecoSimple interactive filtering tool that's remarkably useful
Liquid PromptAdaptive prompt for Bash & Zsh
AnanicyShell daemon created to manage processes’ IO and CPU priorities
cheat.shCommunity driven unified cheat sheet
ripgrepRecursively search directories for a regex pattern
exaA turbo-charged alternative to the venerable ls command
OCRmyPDFAdd OCR text layer to scanned PDFs
WatsonTrack the time spent on projects
fontpreviewQuickly search and preview fonts
fdWonderful alternative to the venerable find
Share this article

Share your Thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.