【发布时间】:2021-09-16 07:51:13
【问题描述】:
是否有任何 Python 方法可以识别 PDF 是否经过 OCR(文本质量很差)与可搜索 PDF(文本质量完美)?
使用 pdf 的元数据
import pprint
import PyPDF2
def get_doc_info(path):
pp = pprint.PrettyPrinter(indent =4)
pdf_file = PyPDF2.PdfFileReader(path, 'rb')
doc_info = pdf_file.getDocumentInfo()
pp.pprint(doc_info)
我发现:
result = get_doc_info(PDF_SEARCHABLE_HAS_BEEN_OCRD.pdf)
{ '/Author': 'NAPS2',
'/CreationDate': "D:20200701104101+02'00'",
'/Creator': 'NAPS2',
'/Keywords': '',
'/ModDate': "D:20200701104101+02'00'",
'/Producer': 'PDFsharp 1.50.4589 (www.pdfsharp.com)'}
result = get_doc_info(PDF_SEARCHABLE_TRUE.pdf)
{ '/CreationDate': 'D:20210802122000Z',
'/Creator': 'Quadient CXM AG~Inspire~14.3.49.7',
'/Producer': ''}
我可以使用 PDF 元数据中的 Creator 检查 PDF 的类型(True PDF 或 OCR PDF)吗?
还有另一种使用python的方法吗?
如果问题没有解决方案,我该如何使用深度学习/机器学习来检测可搜索的 pdf 类型(True 或 OCR)?
这是一个了解 TRUE PDF 和 OCR PDF 区别的视频:https://www.youtube.com/watch?v=xs8KQbxsMcw
【问题讨论】:
标签: python machine-learning pdf deep-learning pdftotext