【问题标题】:converting pdf file to excel with images in the table using python使用python将pdf文件转换为带有表格中图像的excel
【发布时间】:2021-04-10 10:46:25
【问题描述】:

我需要转换的 pdf 文件将在表格中包含图像。我想将pdf表格中的文本和图像转换为excel。请为我推荐合适的库。

【问题讨论】:

    标签: python tabula


    【解决方案1】:

    您需要编写一个脚本来读取和检测字符和 Excel 单元格。您可以使用 open-cv 和内置的字符识别工具来做到这一点,但我不知道这有多容易。我能想到的另一种方法是制作一个可以从图像中识别 excel 表格的 ML 模型。不过这真的很难,需要很多经验。

    【讨论】:

      【解决方案2】:

      您可以使用PikePDF从pdf中提取图像:

      from pikepdf import Pdf, PdfImage
      
      filename = "sample.pdf"
      example = Pdf.open(filename)
      
      for i, page in enumerate(example.pages):
          for j, (name, raw_image) in enumerate(page.images.items()):
              image = PdfImage(raw_image)
              out = image.extract_to(fileprefix=f"{filename}-page{i:03}-img{j:03}")
      

      提取图像后,您可以使用OCR 将图像转换为表格

      【讨论】:

        猜你喜欢
        • 2013-10-05
        • 2021-07-05
        • 2012-07-22
        • 1970-01-01
        • 1970-01-01
        • 2020-02-29
        • 2020-06-27
        • 2015-05-05
        • 1970-01-01
        相关资源
        最近更新 更多