Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofd转pdf的时候报错 #36

Open
my-fastcms opened this issue Oct 22, 2024 · 0 comments
Open

ofd转pdf的时候报错 #36

my-fastcms opened this issue Oct 22, 2024 · 0 comments

Comments

@my-fastcms
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant