需要安装:iTextSharp
static void Main(string[] args)
{
//创建阅读器,是文件路径
PdfReader pdfReader = new PdfReader(@"e:\mypdf.pdf");
//获取文档内容
string strContent = string.Empty;
//对每一页内容进行提取
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
string pageContent = PdfTextExtractor.GetTextFromPage(pdfReader,page, strategy);
//将每一页内容放入字符串中
strContent += pageContent;
}
//关闭读取工具
pdfReader.Close();
}
网友评论