first, apologies if this has been asked before - I searched for a while through the existing posts, but could not find support.

I am interested in a solution for Fedora to OCR a multipage non-searchable pdf and to turn this pdf into a new pdf file that contains the text layer on top of the image. On Mac OSX or Windows we could use Adobe Acrobat, but on Linux, specifically on Fedora?

https://snippets.webaware.com.au/howto/pdf-ocr-linux/ seems to describe a solution - but unfortunately I am already lost when retrieving exact-image.

  • There is a problem with the nice pdfocr script that the page you are linking to recommends: it relies upon pdftk which is essentially deprecated (for two reasons, its dependence on libgcj and on iText5+). So a different solution is needed anyway... – Maxim Mar 14 '17 at 6:04

Best and easyest way out there is to use pypdfocr it doesn't change the pdf. pypdfocr is a python module link here.

pypdfocr your_document.pdf

At the end you will have another your_document_ocr.pdf the way you want it with searchable text. The app doesn't change the quality of the image. Increases the size of the file a bit by adding the overlay text.

I think the command is pretty easy that it doesn't need any GUI. Maybe installing pypdfocr is a bit more verbose:

sudo dnf -y install tesseract 
pip install pypdfocr 

Update 3rd november 2018:

pypdfocr is no longer supported since 2016 and I noticed some problems due to not being mentained. ocrmypdf(module) does a symiliar job and can be used like this:

ocrmypdf in.pdf out.pdf

To install:

pip install ocrmypdf


sudo apt install ocrmypdf  #ubuntu
sudo dnf -y install ocrmypdf #fedora
  • why do you install (using apt) ocrmypdf in ubuntu, but installs tessaract in fedora? I think you made a typo – iuridiniz Dec 28 '18 at 15:27
  • @iuridiniz fixed it. It was a mistake that slipped in – Eduard Florinescu Dec 28 '18 at 16:14

After learning that tesseract can now also produce searchable pdfs, I found the script sandwich: http://www.tobias-elze.de/pdfsandwich/

after installing dependencies (this might not be the complete list)

sudo dnf install svn ocaml unpaper tesseract

I followed the script's guide for compiling from source

Compile from sources

pdfsandwich is open source software (license: GPL). You can download the sources either as .tar.bz2 package from the download area on the project website or check them out by subversion:

svn checkout svn://svn.code.sf.net/p/pdfsandwich/code/trunk/src pdfsandwich

If OCaml is installed on your system, you can compile and install as follows:

cd pdfsandwich
sudo make install

and this now allows me to run

sandwich multipaged-non-searchable.pdf

resulting in a searchable pdf.


An easy tool available in Ubuntu is 'ocrfeeder' it allows the generation of PDFs with OCR text overlaid on the original documents. It makes use of Tesseract plus other OCR engines (not sure which) and provides for image rotation/'unpaper', etc, as well.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.