0
votes

While extracting text from PDF file using iTextSharp, I am getting this error: "Could not find image data or EI"

This error occurs on particular pages that contains image only.

Could the reason be because I am trying to extract the text without checking whether there is any text content in the page?

2
The InlineImageParseException("Could not find image data or EI") is thrown while parsing an inline image which is not properly closed by an EndImage tag (or the content of which was garbled in a way to make iText miss that tag). Can you provide the file for analysis? - mkl
Sorry guys.. That is very confidential document so i couldn't share to you. if you find any solution please let me know. Thanks - user2463266
What version of iTextSharp are you using? There's talk that this was fixed in 5.0.6 here itext-general.2136553.n4.nabble.com/… Otherwise the only two solutions I see for you are to fix the PDF or to wrap with a try/catch - Chris Haas
Am using iTextSharp 5.4.4.0.. i already done wrap with try/catch blocks..then i am going to 5.0.6. if there is any issue let you know.. Thanks your quick response...Thanks a lot.. - user2463266

2 Answers

1
votes

Inline images are not specified very well in the PDF specification. The image data should be contained between ID and EI operators. But there's a possibility the image data itself contains "EI". In iText(Sharp) image data is read until <whitespace>EI<whitespace> is encountered. However, there are PDFs that have EI<whitespace> as the end of inline image data. For those inline images iText(Sharp) throws this exception.

If this is the issue with your PDF, you can probably fix it by changing found == 1 to found <= 1 in InlineImageUtils.ParseInlineImageSamples() here: http://sourceforge.net/p/itextsharp/code/HEAD/tree/trunk/src/core/iTextSharp/text/pdf/parser/InlineImageUtils.cs#l337

-1
votes

This is because the computer resolution is too high and reprint uses lower resolution. That's ok, but fundamental profile is still from source code. That is to say support many computer resolution.