c# - 使用 itext7 在 net core 中读取 PDF 返回“\n\n\n\n\n....”
问题描述
我有一个 netcore 3 应用程序来阅读和拆分包含我工作的一些公司的薪水的 PDF。
自上次构建以来,此应用程序运行良好……我的方式是,PDF 阅读器开始无法解析任何 PDF 的内容。
PDF 仅使用意大利语单词构建,没有特殊字符。几张桌子和一个标志。由于隐私,我无法附上它。
public PaycheckSplitter Read()
{
using (var reader = new PdfReader(new MemoryStream(this._stream)))
{
var doc = new PdfDocument(reader);
this.Paycheck = new PaychecksCollection();
for (int i = 1; i <= doc.GetNumberOfPages(); i++)
{
PdfPage page = doc.GetPage(i);
string text = PdfTextExtractor.GetTextFromPage(page, new LocationTextExtractionStrategy());
if (text.Contains(Consts.BpEnd)) break;
// trying to find something by regex... btw text contains only a sequence of \n\n\n\n...
string cf = Consts.CodFiscale.Match(text).Value;
this.Paychecks.Add(new Paycheck(cf), i);
}
doc.Close();
}
return this;
}
有什么我能做的吗?据我所知......免费阅读PDF文本的唯一也是最好的方法是iText7......
解决方案
推荐阅读
- reactjs - 函数内部的 Jest 模拟函数
- reactjs - React 导航事件监听器被多次调用
- unity3d - Unity OBJECTS 中没有阴影
- javascript - 我正在使用 chart.js 制作图表,但问题是当我单击添加按钮时,包含图表的框不断下降
- ios - 无法在 UIView 上画线
- r - Lavaan 中简单审核模型的模型语法(带自举)
- c# - ASP.NET Core MVC - 从控制器操作返回 ViewResult 或 JSON
- c - 打印文件内容,帮助理解不同的输出
- google-apps-script - 如何将范围复制到 Google Sheets Apps 脚本中的数组并删除数组重复项?
- wordpress - 数量自定义字段作为 WordPress 中标题的一部分