renoyuan / easyofd

use python parse OFD file: finished ofd2img ofd2pdf pdf2ofd img2ofd ;(纯 python的ofd解析与pdf转换)
Apache License 2.0
208 stars 28 forks source link

ofd转pdf的时候报错 #36

Open my-fastcms opened 1 month ago

my-fastcms commented 1 month ago
def ofd_to_pdf(self, ofd_file_path):
    output_pdf_path = ofd_file_path[:-4] + ".pdf"
    with open(ofd_file_path, "rb") as f:
        ofdb64 = f.read()
        ofd = OFD()  # 初始化OFD 工具类
        ofd.read(ofdb64, fmt = "binary")  # 读取ofdb64
        # print(ofd.data) # ofd.data 为程序解析结果
        pdf_bytes = ofd.to_pdf()  # 转pdf

        with open(output_pdf_path, "wb") as f:
            f.write(pdf_bytes)

Traceback (most recent call last): File "D:\robot_develop\code\approval_robot\service\ChuZhengService.py", line 113, in ofd_to_pdf ofd.read(ofdb64, fmt = "binary") # 读取ofdb64 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\robot_develop\Miniconda3\envs\crawler_robot\Lib\site-packages\easyofd\ofd.py", line 51, in read self.data = OFDParser(ofd_f)(save_xml=save_xml, xml_name=xml_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\robot_develop\Miniconda3\envs\crawler_robot\Lib\site-packages\easyofd\parser_ofd\ofd_parser.py", line 350, in call self.file_tree = FileRead(self.ofdb64)(save_xml=save_xml, xml_name=xml_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\robot_develop\Miniconda3\envs\crawler_robot\Lib\site-packages\easyofd\parser_ofd\file_deal.py", line 77, in call self.buld_file_tree() File "D:\robot_develop\Miniconda3\envs\crawler_robot\Lib\site-packages\easyofd\parser_ofd\file_deal.py", line 63, in buld_file_tree if "xml" not in file else xmltodict.parse(open(f"{abs_path}" , "r", encoding="utf-8").read()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\robot_develop\Miniconda3\envs\crawler_robot\Lib\site-packages\xmltodict.py", line 359, in parse parser.Parse(xml_input, True) xml.parsers.expat.ExpatError: duplicate attribute: line 2, column 64

renoyuan commented 3 days ago

ofd 文件发我