使用iTextSharp从PDF文件提取文本时,出现此错误:&“找不到图像数据或EI&". [英] While extracting text from PDF file using iTextSharp, I am getting this error: "Could not find image data or EI"

查看:135
本文介绍了使用iTextSharp从PDF文件提取文本时,出现此错误:&“找不到图像数据或EI&".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iTextSharp从PDF文件提取文本时,出现此错误:找不到图像数据或EI"

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?

推荐答案

在PDF规范中没有很好地指定嵌入式图像.图像数据应包含在IDEI运算符之间.但是图像数据本身可能包含"EI". 在iText(Sharp)中,读取图像数据,直到遇到<whitespace>EI<whitespace>.但是,有些PDF以EI<whitespace>作为内嵌图像数据的结尾.对于那些内联图像,iText(Sharp)会抛出此异常.

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.

如果这是您的PDF的问题,则可以通过在以下位置将InlineImageUtils.ParseInlineImageSamples()中的found == 1更改为found <= 1来解决它: http ://sourceforge.net/p/itextsharp/code/HEAD/tree/trunk/src/core/iTextSharp/text/pdf/parser/InlineImageUtils.cs#l337

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

这篇关于使用iTextSharp从PDF文件提取文本时,出现此错误:&amp;“找不到图像数据或EI&amp;".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆