我正在使用 iTextSharp.dll 来读取 PDF 文件的内容。在 Windows 服务器上它可以正常工作,但在 Mono 平台上却不行。
单声道错误:
Server Error in '/' Application
Object reference not set to an instance of an object
我正在使用这段代码:
PdfReader reader = new PdfReader(filename);
StringBuilder text = new StringBuilder();
for (int page = 1; page <= reader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(reader, page, strategy);
currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
text.Append(currentText);
reader.Close();
}