是否可以使用Python在PDF中的某些区域进行OCR?
是否可以使用Python在PDF中的某些区域进行OCR?我正在尝试构建一个程序,以从每个PDF表中提取一些信息,例如Autodesk Bim360做什么
Is it possible to perform an OCR in certain area in a PDF with python? I am trying to build a program to extract some information from every PDF sheet like what Autodesk BIM360 do
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
免责声明:我是
Borb
的作者(此答案中使用的库)Borb
是播放的开源,纯Python PDF库与其他著名的图书馆很好。例如,您可以插入pil
图像,或matplotlib
图表,您可以使用pytesseract
将OCR应用于文档。如果您想了解更多信息,则有一个大型示例存储库。您可以找到一个工作示例ocr 也是。
我将在此处重复此示例以使其完整性:
这里发生的事情是OCR过程将其结果倾倒在PDF的无形层中(这些称为可选内容组)。因此,名称
ocrasoptionalContentGroup
。之后,您可以再次存储
文档
,它似乎包含文本,您ll可以搜索它,选择文本以及您曾经使用的所有内容。
disclaimer: I am the author of
borb
(the library used in this answer)borb
is an open-source, pure Python PDF library that plays nice with other famous libraries. e.g. you can insertPIL
images, ormatplotlib
charts, and you can usepytesseract
to apply OCR to your document.There is a large examples repository in case you want to learn more. You can find a working example of OCR there as well.
I'll repeat the example here for completeness:
What's happening here is that the OCR process is dumping its results in an invisible layer of the PDF (these are called optional content groups). Hence the name
OCRAsOptionalContentGroup
.Afterwards, you can store the
Document
again, and it will appear to contain text, youll be able to search it, select the text, and everything you
re used to.