30

I have scanned about 80 pages into gray scale pdf (image format). The end size of the file is about 70MB, which is very huge.

Now I am looking for a method to convert the grayscale image-based PDF file into a simple black/white text-based PDF file.

I have done many attempts with gs but with no success (only a few percent recovery). If any expert has some idea, kindly let me know.

  • You need some OCR tool. Look at Tesseract ubuntuforums.org/showthread.php?t=880471 – Nikita U. Mar 14 '13 at 23:26
  • 3
    If you're interested in keeping the PDF images as-is and adding text to it, have a look at question Adding OCR info to a PDF. – colan Sep 6 '14 at 13:22
  • If you could post a link to (for example) one-page example we could test solutions... – Rmano Apr 30 '15 at 8:23
  • It's not an OCR solution but askubuntu.com/a/3387/16395 helps a lot (although 72dpi is a bit on the low side, I have better results with 120). – Rmano Apr 30 '15 at 8:29
  • Does YAGF work correct with Ubuntu 16.04? If I load an image or a pdf-document the programm aborts without any error message. Under Ubuntu 14.04 I had no problems. H.Roos – Hubert Roos Nov 5 '16 at 11:08
21

gImageReader is a simple GTK+ front-end to tesseract-ocr.

sudo apt-get install gimagereader tesseract-ocr

sorry for the german text

  • 1
    You should also install the document's language to improve the OCR, with sudo apt-get install tesseract-ocr-[lang], replacing lang by the language code, like deu for Deutsch, por for Portuguese, etc. – estibordo Sep 7 '18 at 13:53
  • This software is ugly. Usability is under zero. Though it tries to do the job, but it's unable to read plain spreadsheet-like tables. Just misses the pages containing them. – Max Yudin Oct 29 '18 at 9:11
7

You can try pdfocr:

 sudo add-apt-repository ppa:gezakovacs/pdfocr
 sudo apt-get update
 sudo apt-get install pdfocr

To execute the syntax is

 pdfocr -i input.pdf -o output.pdf

where input.pdf is the name of the input file and output.pdf the output file.

By default it uses Tesseract. To install it:

 sudo apt-get install tesseract-ocr

pdfocr creates an embedded text layer.

  • Great! Interestingly after performing the steps above the file is now searchable in Adobe Acrobat DC but not in Preview. – lukeaus Aug 1 '17 at 21:55
  • 2
    This repository doesn't support xenial – Max N Dec 18 '17 at 21:19
  • You can try installing an old version of pdfocr, if you install wily version on xenial it works ok. To do this add "deb ppa.launchpad.net/gezakovacs/pdfocr/ubuntu wily main" and "deb-src ppa.launchpad.net/gezakovacs/pdfocr/ubuntu wily main" to /etc/apt/sources.list and then "sudo apt update" and "sudo apt-get install pdfocr" – rafmunozf Jan 28 '18 at 21:09
  • 1
    pdfocr is a script which automates the following process: 1. Splitting the PDF file into separate pages using pdftk 2. Extracting out the image data using pdfimages 3. Doing OCR (optical character recognition) using cuneiform 4. Embedding the detected text back into the PDF file using hocr2pdf 5. Merging together the files using pdftk. (quoting from ubuntuforums.org/showthread.php?t=1456756 ) – Tommy Trussell Aug 16 '18 at 14:01
0

pdfsandwich

It loads tesseract and others on install. Easy one step solution and can be scripted. It can use hocr2pdf to create a plain text pdf, but its not ready for prime time...yet. The default uses tesseract and creates a "sandwiched" pdf: image + text underneath.

The embedded image can be removed with commands like:

gs -o ocr_noIMG.pdf -sDEVICE=pdfwrite -dFILTERIMAGE ocr_image.pdf

but the text is hidden, so it looks like a blank page.

Loading the PDF into LibreOffice Draw exposes the text and the image can be deleted manually.

-1

In your pdf file, right-click and save each page as image (or find some tool that does all pages automatically)

Open Ubuntu software center. Search for tesseract. This will find YAGF which you should install. In YAGF, click on File -> Open Image and load your image. Then click on File -> Recognize.

I had 100% accuracy in my first test.

-1

For the graphical interface suggested by @A.B. on ubuntu 14.04 you should follow:

ocr tesseract on ubuntu 14.04

or anyway, add to the repository list:

sudo add-apt-repository ppa:sandromani/gimagereader
sudo apt-get update

before this works:

sudo apt-get install gimagereader

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.