【发布时间】:2018-07-22 19:38:52
【问题描述】:
我正在尝试使用PyPDF2 库来读取由波兰字符(例如 ń、ś 等)组成的 pdf 文件,但在使用 extractText() 函数后,输出字符串缺少波兰字符。有没有办法仍然使用 PyPDF2 库但首先正确编码、解码 pdf 文件?
我试图用 encoding='utf-8' 和 'latin-1' 打开文件,但没有成功。感谢您的帮助!
代码sn-p:
file = open(myPDFfile, "rb")
pdfreader = PyPDF2.PdfFileReader(file, strict=True)
page_obj = pdfreader.getPage(0)
page_txt = page_obj.extractText()
page_txt_split = page_txt.split()
【问题讨论】:
标签: python file pdf encode pypdf2