Python pdftotext 错误:poppler 错误创建文档

问题描述

我正在使用 pdftotext 将文件夹中的多个 pdf 文件转换为文本文件。 PDF 文件是用韩语编写的,包含图像。它们可以毫无错误地打开,但我得到 Error: poppler error creating document

我该如何解决这个问题?

import pdftotext
import os

directory = "/downloads"

for filename in os.listdir(directory):
    if filename.endswith(".pdf"):
        pathname = os.path.join(directory,filename)
        
        with open(pathname,'rb') as f: #rb
            pdf = pdftotext.PDF(f)
            
        txtname = pathname.replace('.pdf','.txt')
        with open(txtname,'w',encoding='utf-8') as text_file:
            for page in pdf:
                text_file.write(page)
        continue

解决方法

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

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

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