iTextSharp v5 GetTextFromPage() throws IndexOutOfRangeException

老子叫甜甜 提交于 2019-12-04 05:49:43

问题


Trying to extract the textual content of a pdf with the following code:

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.

Any help is appreciated.

hofnarwillie


回答1:


I resolved this issue by updating my version of iTextSharp from 5.1 to 5.2.



来源:https://stackoverflow.com/questions/8578793/itextsharp-v5-gettextfrompage-throws-indexoutofrangeexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!