python新手,试着转pdf为excel文件,但是提取pdf文本的时候就报错:”AttributeError: 'LTChar' object has no attribute 'graphicstate'“,是不是少安装了什么?麻烦大佬们帮忙看看
源代码:
path = "D:/python测试题/2020年8月公路旅客运输量.PDF"
with pdfplumber.open(path) as pdf:
print(pdf)
print(type(pdf))
print("文档信息:",pdf.metadata)
print("pdf文档总页数:",len(pdf.pages))
first_page = pdf.pages[0]
print('pdf页码:',first_page.page_number)
print('pdf页宽:',first_page.width)
print('pdf页高:',first_page.height)
first_page = pdf.pages[0]
test = first_page.extract_text()
print(test)
报错:
换一下 PyPDF2 或 pdfminer 库来提取 PDF 文本吧
pip install PyPDF2
pip install pdfminer
请问问题解决了吗?遇到了同样的问题,不知道怎么办
Yes, I did remove pdfminer and used pdfminer.six instead in the same project with pdfplumber 0.6.2 and it works for both environments!
你看这段英文,说是先卸载了三个库,然后重按就可以了