无法将“iTextSharp.text.pdf.PdfLiteral”类型的对象转换为“iTextSharp.text.pdf.PdfNumber”类型。
代码:
StringBuilder text = new StringBuilder();
SimpleTextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
for (int p = 1; p <= reader.NumberOfPages; p++)
{
text.AppendLine(PdfTextExtractor.GetTextFromPage(reader, p, strategy));
}
reader.Close();
return text.ToString();
只有很少的 pdf 才会出现此错误。有任何想法吗?
堆栈跟踪:
at iTextSharp.text.pdf.parser.PdfContentStreamProcessor.ShowTextArray.Invoke(PdfContentStreamProcessor processor, PdfLiteral oper, List`1 operands)
at iTextSharp.text.pdf.parser.PdfContentStreamProcessor.InvokeOperator(PdfLiteral oper, List`1 operands)
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)
at DCS.Common.PDF.Functions.GetTextPdf(PdfReader reader) in C:\Users\rmaldonado\Documents\Visual Studio 2008\Projects\DCS\Contract\Common\PDF\Functions.cs:line 35
at DCS.Common.PDF.Functions.ParsePDF(Byte[] bytes) in C:\Users\rmaldonado\Documents\Visual Studio 2008\Projects\DCS\Contract\Common\PDF\Functions.cs:line 23
at DCS.CAPPS.BLL.Common.Attachment.ReParseText() in C:\Users\rmaldonado\Documents\Visual Studio 2008\Projects\DCS\Contract\ContractBLL\Common\Common.cs:line 1120