PDF Text Extraction Approach Using OCR [closed]
Asked Answered
B

4

6

Has anybody attempted to extract text from a PDF using an OCR library and Java? What did you find to be the most reliable library for text extraction. Most of the approaches I've seen (tesseract, GOCR) are C libraries that would require some JNI code to be written.

I'm familiar with pdfbox, which is now an Apache incubator project at version 0.8.x, but it's text extraction isn't always accurate. I'm looking for an alternative approach that is somewhat more reliable.

I've not tried Asprise JavaPDF yet, in the process of trying that, but wanted to know more about the OCR approach (if it's possible).

Any help would be appreciated.

Balls answered 22/4, 2009 at 16:38 Comment(2)
Are you using a structured PDF? If you are you have the ability in JAVA to grab the text from the PDF metadata.Protector
No, not all of the PDF's are structured.Balls
C
7

If you have a text-based PDF, I'd strongly recommend PDFTextStream. It's not free, but licensing is reasonable, and it is much much better than PDFBox. PDFBox chokes on many PDF files which are generated by newer tools, and is not too consistent about PDFs it can handle. PDFTextStream handles any PDF I throw at it, including PDFs with embedded PNG images, which PDFBox can not do.

If you heckle the PDFTextStream folks to add OCR, they may listen up.

Consentaneous answered 22/4, 2009 at 18:58 Comment(4)
Thanks, sounds good, pity about the price though...Balls
Several years later, but now PDFTextStream has a free version (with a 1 Tread cap)Yoshikoyoshio
If the PDF is already text-based, why discuss OCR? Just use PDFBox, iText, PDFTextStream, or whatever to parse the text. OCR is for times when the PDF is an image, say from a scanner. If the PDF is a scanned image, neither PDFBox, iText, nor PDFTextStream will help you.Coulson
I have a Text-based PDF, the language is not English. When I read the text using PDFBox all the characters are messed up. So the only option left to try is OCR. Hence we need to discuss OCR.Emplace
U
2

We use ABBYY FineReader Engine 11. They have java wrapper.

Pros:

  • It works great with all the languages (English, Russian, Uzbek etc) and doing real OCR (even if you have pdf without OCR they perform rendering at first and OCRing).

Cons:

  • It costs. You have to buy developer license and end-user license.

  • And it is EXTREMELY slow.

Uralian answered 8/4, 2015 at 9:14 Comment(1)
Thanks for answering and your honesty about the product. For some years, questions asking to recommend tools are off-topic, and answering them is considered 'not done'. (actually, the question should be deleted if it doesn't have any use any more)Maxine
F
1

If you want to extract OCR from text based PDF you may have to convert it to an image first.

Fifine answered 22/4, 2009 at 16:53 Comment(0)
P
1

You can use Java wrappers of Tesseract - tesjeract or Tess4J - to perform OCR. However, for PDF, you'll need to convert to image (PNG or TIFF) first before feeding it to the OCR engine.

VietOCR calls Tesseract executable to perform the text extraction. It uses GhostScript to do PDF-to-image conversion.

Pinkeye answered 15/5, 2011 at 0:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.