【问题标题】:Pdf data extraction from scanned pdf using python使用python从扫描的pdf中提取pdf数据
【发布时间】:2019-08-22 09:28:15
【问题描述】:

我正在通过 tesseract ocr 从扫描的 pdf 中提取数据,我能够提取数据,但准确性不好。在很多地方,它显示错误的数据,所以我可以通过 python 获得 100% 准确的数据。

首先我将 pdf 转换为 jpg 格式,然后我使用 tesseract 模块从图像中提取数据。

from PIL import Image
import pytesseract

text=(pytesseract.image_to_string(Image.open(r"C:\Users\sumesh\Desktop\ip\ip\pdf11.jpg")))
text=repr(text)
text=text.replace(r"\n","")
print(text)

我希望从 pdf 获得正确的数据,但我得到了不同的数据,例如 z 显示 2,5 是 s,1 是 I,等等

【问题讨论】:

    标签: python-3.x ocr python-tesseract pdfminer pdf-extraction


    【解决方案1】:

    希望以下小改动对您有所帮助。

    from PIL import Image
    import pytesseract
    
    text=str(pytesseract.image_to_string(Image.open(r"C:\Users\sumesh\Desktop\ip\ip\pdf11.jpg"),lang='eng'))
    
    text=text.replace("\n","")
    
    print(text)
    

    【讨论】:

    • 这可能是正确的答案,但如果它还包括为什么这是正确的答案会更有帮助:)
    【解决方案2】:

    请在文件路径后使用“DPI=500”,这可能会有所帮助.. 有关更多信息,您可以关注我在此处发布的答案How to convert .png images to searchable PDF/word using Python

    【讨论】:

      猜你喜欢
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 2018-04-18
      • 1970-01-01
      • 2017-04-02
      相关资源
      最近更新 更多