【问题标题】:How to convert PDF document to JSON Using Python script如何使用 Python 脚本将 PDF 文档转换为 JSON
【发布时间】:2020-09-19 23:54:15
【问题描述】:

尝试使用 python 将 PDF 表单转换为 JSON 数据

示例 PDF 格式:

代码:

import PyPDF2
pdf_file = open('C:\\Users\\Desktop\\data.pdf', 'rb')
read_pdf = PyPDF2.PdfFileReader(pdf_file)
number_of_pages = read_pdf.getNumPages()
page = read_pdf.getPage(0)
page_content = page.extractText()
import json
data = json.dumps(page_content)
formatj = json.loads(data)

但我没有得到正确的 JSON 格式的输出

【问题讨论】:

  • 试试this链接。如果这是你的意思,那么这个 Q 是重复的。
  • 那么你得到的是什么格式?

标签: python json pandas dataframe pypdf


【解决方案1】:

他会通过这个得到一个字符串。你需要先将page_content转换成dictionary

【讨论】:

    猜你喜欢
    • 2018-06-24
    • 1970-01-01
    • 2019-04-04
    • 1970-01-01
    • 1970-01-01
    • 2013-07-30
    • 1970-01-01
    • 1970-01-01
    • 2018-06-03
    相关资源
    最近更新 更多