简体   繁体   English

iTextSharp v5 GetTextFromPage()抛出IndexOutOfRangeException

[英]iTextSharp v5 GetTextFromPage() throws IndexOutOfRangeException

Trying to extract the textual content of a pdf with the following code: 尝试使用以下代码提取pdf的文本内容:

PdfReader reader = new PdfReader(path);
string strText = string.Empty;

for (int page = 1; page <= reader.NumberOfPages; page++)
{
    string s = PdfTextExtractor.GetTextFromPage(reader, page);
    strText += " " + s;                
}
reader.Close();

NumberOfPages returns 257, but at page 227, GetTextFromPage() throws a IndexOutOfRangeException. NumberOfPages返回257,但是在第227页,GetTextFromPage()抛出IndexOutOfRangeException。

Any help is appreciated. 任何帮助表示赞赏。

hofnarwillie 霍那威利

我通过将iTextSharp的版本从5.1更新到5.2解决了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM