python办公自动化(5)识别PDF文件中文字

python办公自动化(5)识别PDF文件中文字

pdfminer官网说明:由于PDF文件具有如此大而复杂的结构,因此将PDF文件解析为一个整体会浪费时间和内存。但是,并非大多数PDF处理任务都需要每个部分。因此,PDFMiner采取了一种惰性分析策略,即仅在必要时才对内容进行解析。要解析PDF文件,您至少需要使用两个类:PDFParser和PDFDocument。这两个对象相互关联。 PDFParser从文件中获取数据并PDFDocument存储。您还需要 PDFPageInterpreter处理页面内容并将PDFDevice其转换为所需的内容。 PDFResourceManager用于存储共享资源,例如字体或图像

from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.layout import LTTextBoxHorizontal, LAParams
from pdfminer.pdfinterp import PDFResourceManager,PDFPageInterpreter
from pdfminer.converter import PDFPageAggregator

def parase_pdf2text(pdf_path,pasword,text_path):
    # Create a PDF parser object associated with the file object.
    parser = PDFParser(open(pdf_path, 'rb'))
    # Create a PDF do
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值