python pdf获取关键字坐标_如何从PDF文件中提取文本和文本坐标?

本文介绍了使用Python的pdfminer库从PDF文件中提取文本和其对应坐标的方法。通过创建PDF解析器、文档对象、资源管理器等,然后进行布局分析,遍历LTTextBoxHorizontal对象,打印出文本及其在页面上的位置。
摘要由CSDN通过智能技术生成

新行在最终输出中转换为下划线.这是我发现的最小工作解决方案.

from pdfminer.pdfparser import PDFParser

from pdfminer.pdfdocument import PDFDocument

from pdfminer.pdfpage import PDFPage

from pdfminer.pdfpage import PDFTextExtractionNotAllowed

from pdfminer.pdfinterp import PDFResourceManager

from pdfminer.pdfinterp import PDFPageInterpreter

from pdfminer.pdfdevice import PDFDevice

from pdfminer.layout import LAParams

from pdfminer.converter import PDFPageAggregator

import pdfminer

# Open a PDF file.

fp = open('/Users/me/Downloads/test.pdf', 'rb')

# Create a PDF parser object associated with the file object.

parser = PDFParser(fp)

# Create a PDF document object that stores the document structure.

# Password for initialization as 2nd parameter

document = PDFDocument(parser)

# Check if the document

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值