Python PDFMiner TypeError:在字符串格式化过程中未转换所有参数

Python PDFMiner TypeError:在字符串格式化过程中未转换所有参数,python,python-3.x,pdfminer,Python,Python 3.x,Pdfminer,我一直在试图找到一种解决方案,将PDF解析为HTML,因此,稍后我将使用beautiful soup分别提取树结构中的所有标题、子项和段落 我在互联网上搜索了一些可用的选项,但到目前为止没有成功。下面是我使用PDFMiner.six将PDF解析为HTML的代码 import sys from pdfminer.pdfdocument import PDFDocument from pdfminer.layout import LTContainer, LTComponent, LTRect, L

我一直在试图找到一种解决方案,将PDF解析为HTML,因此,稍后我将使用beautiful soup分别提取树结构中的所有标题、子项和段落

我在互联网上搜索了一些可用的选项,但到目前为止没有成功。下面是我使用PDFMiner.six将PDF解析为HTML的代码

import sys
from pdfminer.pdfdocument import PDFDocument
from pdfminer.layout import LTContainer, LTComponent, LTRect, LTLine, LAParams, LTTextLine
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.pdfdevice import PDFDevice, TagExtractor
from pdfminer.pdfpage import PDFPage
from pdfminer.converter import XMLConverter, HTMLConverter, TextConverter
from pdfminer.image import ImageWriter
from io import StringIO, BytesIO
from bs4 import BeautifulSoup
import re
import io



def convert_pdf_to_html(path):
    rsrcmgr = PDFResourceManager()
    retstr = StringIO()
    outfp = BytesIO()
    codec = 'utf-8'
    laparams = LAParams()
    device = HTMLConverter(rsrcmgr, outfp, imagewriter=ImageWriter('out'))
    fp = open(path, 'rb')
    interpreter = PDFPageInterpreter(rsrcmgr, device) 
    password = ""
    maxpages = 0 #is for all
    caching = True
    pagenos=set()
    for page in PDFPage.get_pages(fp, pagenos, maxpages=maxpages, password=password,caching=caching, check_extractable=True):
        interpreter.process_page(page)
    fp.close()
    device.close()
    str = retstr.getvalue()
    retstr.close()
    return str

convert_pdf_to_html('PDF - Remraam Ph 1 Mosque.pdf')
但是,上面的代码返回以下错误,我无法修复,如果您能提供帮助,将不胜感激,谢谢

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pdfminer\pdftypes.py in decode(self)
    293                 data = ccittfaxdecode(data, params)
    294             elif f == LITERAL_CRYPT:
--> 295                 raise PDFNotImplementedError('Crypt filter is unsupported')
    296             else:
    297                 raise PDFNotImplementedError('Unsupported filter: %r' % f)

TypeError: not all arguments converted during string formatting

pdfminer.six包不支持带有加密筛选器的pdf。它确实支持其他加密方法。与Crypt过滤器的区别在于,它将描述算法定义为一个参数,而不是一个固定的过滤器

从Pdf参考手册:

密码过滤器(PDF 1.5)允许文档级安全处理程序(参见第3.5节“加密”)确定应使用哪些算法对输入数据进行解密。此文件的解码参数字典中的Name参数 过滤器(见表3.12)指定文档中的哪个命名密码过滤器 (参见第3.5.4节“密码过滤器”)


如果需要此功能,可以创建一个

一个快速更新,我已经修复了这个问题,只需卸载并安装Anaconda,然后我就通过coda安装了pdfminer.six。我想pip安装对我来说不太合适。使用coda install以任何方式安装软件包。。包名称

完全复制,考虑删除这个或另一个。