You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Kishore Babu <kb...@envistacorp.com> on 2012/10/12 15:47:40 UTC
extracting text from image using pdfbox
Hi All,
Is it possible to extract text from an image (JPEG) using pdfbox or is there any open source java code for this?
When I try to convert pdf to text, it is showing blank output. Then I converted into JPEG image. The image contains the text properly, which I am failing to extract.
For normal pdf documents I am extracting text nicely using the standard process but when the pdf document is an image, I am failing to extract the text that is present in the image.
Can anyone give directions on this, please?
Thanks in advance.
Regards,
[cid:image011.jpg@01CDA8AE.3F12B960]<http://www.envistacorp.com/>
Kishore Babu I Developer
email: kbabu@envistacorp.com<ma...@envistacorp.com>
office: 040.66417681
www.envistacorp.com<http://www.envistacorp.com>
Subscribe<http://pages.exacttarget.com/page.aspx?QS=472529ec60bdf32a36ac1f221ebc1706b66778f96833e451f77fe13f8e4cf0db> to enVista's Newsletter!
[cid:image012.jpg@01CDA8AE.3F12B960]<http://www.facebook.com/home.php?#%21/pages/enVista/281494945342?ref=search> [cid:image013.jpg@01CDA8AE.3F12B960] <http://twitter.com/enVistaSpplyChn> [cid:image014.jpg@01CDA8AE.3F12B960] <http://www.linkedin.com/companies/envista>
[cid:image015.jpg@01CDA8AE.3F12B960]<http://www.inc.com/inc5000/profile/envista>
RE: extracting text from image using pdfbox
Posted by Kishore Babu <kb...@envistacorp.com>.
Thanks you very much.
Regards,
Kishore Babu I Developer
email: kbabu@envistacorp.com
office: 040.66417681
www.envistacorp.com
Subscribe to enVista's Newsletter!
-----Original Message-----
From: peter.murray.rust@googlemail.com [mailto:peter.murray.rust@googlemail.com] On Behalf Of Peter Murray-Rust
Sent: Monday, 15 October, 2012 11:46 AM
To: users@pdfbox.apache.org
Subject: Re: extracting text from image using pdfbox
On Mon, Oct 15, 2012 at 6:17 AM, Kishore Babu <kb...@envistacorp.com> wrote:
> Hi Peter,
> Thank you very much for the reply. Unfortunately, the image I am
> dealing are the scanned one.
>
> I will update my result if I succeed in using the mentioned line
> detection algorithms.
>
> There is an excellent explanation of everything involved in OCR at :
http://sudokugrab.blogspot.com.au/2009/07/how-does-it-all-work.html . This is a hard problem but the better your scan the easier it becomes. if you have good contrast, modern typefaces, no/little skewing, and a well understood character set then you have a chance.
--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069
Re: extracting text from image using pdfbox
Posted by Peter Murray-Rust <pm...@cam.ac.uk>.
On Mon, Oct 15, 2012 at 6:17 AM, Kishore Babu <kb...@envistacorp.com> wrote:
> Hi Peter,
> Thank you very much for the reply. Unfortunately, the image I am dealing
> are the scanned one.
>
> I will update my result if I succeed in using the mentioned line detection
> algorithms.
>
> There is an excellent explanation of everything involved in OCR at :
http://sudokugrab.blogspot.com.au/2009/07/how-does-it-all-work.html . This
is a hard problem but the better your scan the easier it becomes. if you
have good contrast, modern typefaces, no/little skewing, and a well
understood character set then you have a chance.
--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069
RE: extracting text from image using pdfbox
Posted by Kishore Babu <kb...@envistacorp.com>.
Hi Peter,
Thank you very much for the reply. Unfortunately, the image I am dealing are the scanned one.
I will update my result if I succeed in using the mentioned line detection algorithms.
Thanks & Regards,
Kishore Babu I Developer
email: kbabu@envistacorp.com
office: 040.66417681
www.envistacorp.com
Subscribe to enVista's Newsletter!
-----Original Message-----
From: peter.murray.rust@googlemail.com [mailto:peter.murray.rust@googlemail.com] On Behalf Of Peter Murray-Rust
Sent: Saturday, 13 October, 2012 1:05 AM
To: users@pdfbox.apache.org
Subject: Re: extracting text from image using pdfbox
On Fri, Oct 12, 2012 at 2:47 PM, Kishore Babu <kb...@envistacorp.com> wrote:
> Hi All,****
>
> Is it possible to extract text from an image (JPEG) using pdfbox or is
> there any open source java code for this?****
>
> ** **
>
> This is a very difficult problem and to solve it completely requires a
large amount of applied artificial intelligence. There are no out-of-the box answers.
However in limited domains there may be heuristic solutions. I am doing exactly this for scientific diagrams (and using PDFBox for parts of this) as an Open Source project. The project will go best when:
* there are lots of diagrams relating to the same subject
* the graphics strokes and characters are preserved as PDF primitives (paths and characters)
* the characters are in common simple fonts (e.g. Helvetica)
This we now have tools which will extract and interpret chemical structures and scientific diagrams (graphs) with a promising degree of precision.
If the characters are present as bitmaps then it is much harder. OCR works best when:
* the fonts are simple and well-known
* there is clear whitespace between the characters
* the characters are aligned with the page axes and are not distorted
* there is no lossy compression algorithm.
I am going to attempt to decipher images in PDFs using PDFBox to extract the images and then line detection algorithms such as http://en.wikipedia.org/wiki/Canny_edge_detector to fine lines and characters. I am optimistic of significant progress but it will be slow and will require heuristics.
The things that make the process harder or impossible are:
* scanned images - the images are often skewed and have variable contrast
* lossy compression such as JPEG. (Look at the JPEG and you will see small satellite pixels from the wavelet algorithm. These make OCR much harder.
BTW if any other reader is interested in hacking (STM) scientific technical medical PDFs using Java code layered on PDFBox and prepared to put in effort at alpha level I'd be delighted to hear from you. But it is *alpha* at best - there are a lot of heuristics that change frequently.
--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069
Re: extracting text from image using pdfbox
Posted by Peter Murray-Rust <pm...@cam.ac.uk>.
On Fri, Oct 12, 2012 at 2:47 PM, Kishore Babu <kb...@envistacorp.com> wrote:
> Hi All,****
>
> Is it possible to extract text from an image (JPEG) using pdfbox or is
> there any open source java code for this?****
>
> ** **
>
> This is a very difficult problem and to solve it completely requires a
large amount of applied artificial intelligence. There are no out-of-the
box answers.
However in limited domains there may be heuristic solutions. I am doing
exactly this for scientific diagrams (and using PDFBox for parts of this)
as an Open Source project. The project will go best when:
* there are lots of diagrams relating to the same subject
* the graphics strokes and characters are preserved as PDF primitives
(paths and characters)
* the characters are in common simple fonts (e.g. Helvetica)
This we now have tools which will extract and interpret chemical structures
and scientific diagrams (graphs) with a promising degree of precision.
If the characters are present as bitmaps then it is much harder. OCR works
best when:
* the fonts are simple and well-known
* there is clear whitespace between the characters
* the characters are aligned with the page axes and are not distorted
* there is no lossy compression algorithm.
I am going to attempt to decipher images in PDFs using PDFBox to extract
the images and then line detection algorithms such as
http://en.wikipedia.org/wiki/Canny_edge_detector to fine lines and
characters. I am optimistic of significant progress but it will be slow and
will require heuristics.
The things that make the process harder or impossible are:
* scanned images - the images are often skewed and have variable contrast
* lossy compression such as JPEG. (Look at the JPEG and you will see small
satellite pixels from the wavelet algorithm. These make OCR much harder.
BTW if any other reader is interested in hacking (STM) scientific technical
medical PDFs using Java code layered on PDFBox and prepared to put in
effort at alpha level I'd be delighted to hear from you. But it is *alpha*
at best - there are a lot of heuristics that change frequently.
--
Peter Murray-Rust
Reader in Molecular Informatics
Unilever Centre, Dep. Of Chemistry
University of Cambridge
CB2 1EW, UK
+44-1223-763069
RE: extracting text from image using pdfbox
Posted by Kishore Babu <kb...@envistacorp.com>.
Thanks Jeremias I will try it.
Regards,
Kishore Babu I Developer
email: kbabu@envistacorp.com
office: 040.66417681
www.envistacorp.com
Subscribe to enVista's Newsletter!
-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Sent: Sunday, 14 October, 2012 1:39 PM
To: users@pdfbox.apache.org
Subject: Re: extracting text from image using pdfbox
Hi,
Apache PDFBox can't help you here, I'm afraid. What you're after is OCR functionality (http://en.wikipedia.org/wiki/Optical_character_recognition)
and PDFBox doesn't provide that. The only thing you can do is to extract the bitmap images using PDFBox and then attempt to decipher the text contained in them using an external OCR process. Just a warning: don't expect an OCR process to be 100% accurate.
If you're looking for an open source OCR engine, Tesseract is probably the most popular one: http://en.wikipedia.org/wiki/Tesseract_%28software%29
HTH
Jeremias Maerki
On 12.10.2012 15:47:40 Kishore Babu wrote:
> Hi All,
> Is it possible to extract text from an image (JPEG) using pdfbox or is there any open source java code for this?
>
> When I try to convert pdf to text, it is showing blank output. Then I converted into JPEG image. The image contains the text properly, which I am failing to extract.
>
> For normal pdf documents I am extracting text nicely using the standard process but when the pdf document is an image, I am failing to extract the text that is present in the image.
>
> Can anyone give directions on this, please?
>
> Thanks in advance.
>
> Regards,
> Kishore Babu I Developer
Re: extracting text from image using pdfbox
Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi,
Apache PDFBox can't help you here, I'm afraid. What you're after is OCR
functionality (http://en.wikipedia.org/wiki/Optical_character_recognition)
and PDFBox doesn't provide that. The only thing you can do is to extract
the bitmap images using PDFBox and then attempt to decipher the text
contained in them using an external OCR process. Just a warning: don't
expect an OCR process to be 100% accurate.
If you're looking for an open source OCR engine, Tesseract is probably
the most popular one: http://en.wikipedia.org/wiki/Tesseract_%28software%29
HTH
Jeremias Maerki
On 12.10.2012 15:47:40 Kishore Babu wrote:
> Hi All,
> Is it possible to extract text from an image (JPEG) using pdfbox or is there any open source java code for this?
>
> When I try to convert pdf to text, it is showing blank output. Then I converted into JPEG image. The image contains the text properly, which I am failing to extract.
>
> For normal pdf documents I am extracting text nicely using the standard process but when the pdf document is an image, I am failing to extract the text that is present in the image.
>
> Can anyone give directions on this, please?
>
> Thanks in advance.
>
> Regards,
> Kishore Babu I Developer