var pdfReader = new PdfReader("xxx.pdf"); StreamWriter output = new StreamWriter(new FileStream("处理结果.txt", FileMode.Create)); int pageCount = pdfReader.NumberOfPages;
for (int pg = ; pg <= pageCount; pg++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
var value = PdfTextExtractor.GetTextFromPage(pdfReader, pg, strategy);
value = value.Replace(" ", "");
Console.WriteLine(value);
output.Write(value);
} output.Flush();
output.Close();
Console.Write("处理完毕");
Console.ReadLine();
该方法读出的汉字不会乱码。