0
我有以下異常在iTextSharp的時候我試圖解析一個PDF文件的NullReferenceException在iTextSharp的
這裏5.0.6庫是PDF文件 https://backup.filesanywhere.com/fs/v.aspx?v=8c726b8f5a6673b56b6d
try
{
string s = null;
MessageBox.Show("Not-Protected");
PdfReader read = new PdfReader(openFileDialog1.FileName);
//MessageBox.Show(read.NumberOfPages.ToString());
for (int i = 1; i <= read.NumberOfPages; i++)
{
s = PdfTextExtractor.GetTextFromPage(read, i, new SimpleTextExtractionStrategy());
MessageBox.Show(s);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
System.NullReferenceException: Object reference not set to an instance of an object.
at iTextSharp.text.pdf.PdfContentParser.ReadArray()
at iTextSharp.text.pdf.PdfContentParser.ReadPRObject()
at iTextSharp.text.pdf.PdfContentParser.Parse(List`1 ls)
at iTextSharp.text.pdf.parser.PdfContentStreamProcessor.ProcessContent(Byte[] contentBytes, PdfDictionary resources)
at iTextSharp.text.pdf.parser.PdfReaderContentParser.ProcessContent[E](Int32 pageNumber, E renderListener)
at iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(PdfReader reader, Int32 pageNumber, ITextExtractionStrategy strategy)
問題尋求幫助調試(「?爲什麼不是這個代碼工作」)必須包括所期望的行爲,一個特定的問題或錯誤的和必要的最短的代碼在問題本身中重現它。沒有明確問題陳述的問題對其他讀者無益。請參閱:[如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 – nvoigt
另外:iText 5.0.6的日期從2011年2月4日開始。這差不多是4年前。目前的版本是5.5.4。在過去的4年裏,許多bug已經得到修復,特別是在PDF解析軟件包中。如果問題無法在當前版本中重現,那麼您正在報告一個已經修復的錯誤(這是毫無意義的)。因此,如果您不希望您的問題被關閉,請向我們展示一份可用於重現當前版本問題的PDF。 –
這裏是提高上述指定的異常的PDF文件的鏈接https://backup.filesanywhere.com/fs/v.aspx?v=8c726b8f5a6673b56b6d – AJ0