编程语言
首页 > 编程语言> > C# 使用 iTextSharp 将 PDF 转换成 TXT 文本

C# 使用 iTextSharp 将 PDF 转换成 TXT 文本

作者:互联网

var pdfReader = new PdfReader("xxx.pdf");
StreamWriter output = new StreamWriter(new FileStream("处理结果.txt", FileMode.Create));

int pageCount = pdfReader.NumberOfPages;
for (int pg = 1; 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();


https://www.cnblogs.com/New-HackerHK/p/14853693.html

 

标签:StreamWriter,pdfReader,C#,www,int,iTextSharp,pg,new,PDF
来源: https://www.cnblogs.com/firespeed/p/16698497.html