应该怎么通过c#来读取PDF文档中红线下面的内容?麻烦回答尽量完整一些
https://www.cnblogs.com/yellow3gold/p/14754911.html 这个代码应该能满足你的需求
https://blog.csdn.net/weixin_38172370/article/details/124515701
你可以看看这个,不要忘记导入NuGet的包
你这个是表格,可以试试这个:C#/VB.NET 提取 PDF 中的表格
可以通过iTextSharp读取PDF文件内容
private string OnCreated(string filepath)
{
try
{
string pdffilename = filepath;
PdfReader pdfReader = new PdfReader(pdffilename);
int numberOfPages = pdfReader.NumberOfPages;
string text = string.Empty;
for (int i = 1; i <= numberOfPages; ++i)
{
iTextSharp.text.pdf.parser.ITextExtractionStrategy strategy = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
text += iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(pdfReader, i, strategy);
}
pdfReader.Close();
return text;
}
catch (Exception ex)
{
StreamWriter wlog = File.AppendText(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase+"\\mylog.log");
wlog.WriteLine("出错文件:" + e.FullPath + "原因:" + ex.ToString());
wlog.Flush();
wlog.Close();return null;
}
}
```
FreeSpire.Pdf
第三方
//文件流
Stream stream = null;
PdfDocument pdf = new PdfDocument();
pdf.LoadFromStream(stream);
StringBuilder content = new StringBuilder();
if (pdf.Pages.Count > 0)
{
//提取PDF所有页面的文本
foreach (PdfPageBase page in pdf.Pages)
{
content.Append(page.ExtractText());
}
}
把这个pdf文件的下载链接发上来