PDFMiner返回PSTypeError:必需文字:<PDFObjRef:82>

问题描述

我正在使用pdfminer从PDF提取文本。 2周前,我提取了60个pdf的文本。今天,我想再次提取文本(相同的pdfs!),我只能检索5个pdfs的文本。我已经完成了Google搜索,但是未找到任何结果。

我没有更改任何代码,但是现在我得到了错误

PSTypeError: Literal required: <PDFObjRef:82>

我正在使用以下功能

def convert_pdf_to_txt_miner2(path):
    manager = PDFResourceManager()
    output = io.StringIO()
    #print(type(retstr))
    codec = 'utf-8'
    laparams = LAParams()
    device = TextConverter(manager,output,laparams=LAParams())
    interpreter = pdfpageInterpreter(manager,device)
    count=1
    text=""
    data=""
    page_no = 0
    fp = open(path,'rb')
    for page in pdfpage.get_pages(fp):
        interpreter.process_page(page)
        data = output.getvalue()
        text= text + "#" + str(count) + "#" + data
        count=count+1
        data = ''
        output.truncate(0)
        output.seek(0)

    device.close()
    output.close()
    return text

此行产生错误

interpreter.process_page(page)

真的很高兴获得帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)