在 C# 中比较两个 pdf 文件的最佳方法是什么?
我想用 C# 检查两个 PDF 文件的文本内容。
I want to check the text content of two PDF file in C#.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想用 C# 检查两个 PDF 文件的文本内容。
I want to check the text content of two PDF file in C#.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
如果它们相同,您可以进行二进制比较。如果要进行上下文比较,您可能需要一个 PDF 库。 这里是一些库。
If they are identical you can do a binary comparison. If for contextual comparison you probably need a PDF library. Here are some libraries.
这并不容易,但我想第一步是获得一个像样的 PDF 库,可以从 PDF 中提取文本。我使用过的一个是 ITextSharp,可从 http://itextpdf.com/ (开源)获得。然后尝试使用 diff 库,例如 DIffer:可重用的 C# diffing 实用程序和类库。祝你好运!
Not going to be easy, but I guess first step would be to get a decent PDF library that can extract the text from PDFs. One I've used is ITextSharp available from http://itextpdf.com/ (open-source). Then try a diff library, such as DIffer: a reusable C# diffing utility and class library. Good luck!
已经有一段时间了,但这个功能对我有用(但不能保证......我不记得我是否在带有嵌入图像或其他内容的 PDF 上尝试过它)。文件中嵌入了 GUID 或某种 ID,您只需将其删除并比较其他所有内容即可。这是代码:
It's been awhile, but this function worked for me (but no guarantees... I don't remember if I tried it on PDF's with embedded images or anything). There is a GUID or some sort of ID embedded in the file, you just need to remove that and compare everything else. Here's the code:
免责声明:我在 Atalasoft 工作。
Atalasoft 的 DotImage SDK 可用于使用 C# 从 PDF 中提取文本。如果 PDF 已经可搜索,您可以轻松获取文本:
否则,您可以使用 OCR 工具检测图像上的文本。
Disclaimer: I work for Atalasoft.
Atalasoft's DotImage SDK can be used to extract the text from PDFs in C#. If the PDFs are already searchable you can easily get to the text:
Otherwise, you could use the OCR tools to detect the text on the image.