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文件,是我哪里用的不对吗 #29

Open
gomatthew opened this issue Sep 6, 2024 · 13 comments

Comments

@gomatthew
Copy link

代码
import base64
import json
from PIL import Image

from easyofd.ofd import OFD

with open(r"/Users/9-6/c4bcb65c0.ofd", "rb") as f:
ofdb64 = str(base64.b64encode(f.read()), "utf-8")
ofd = OFD() # 初始化 OFD 工具类
ofd.read(ofdb64, save_xml=False, xml_name="testxml") # 读取 ofdb64
# print(ofd.data) # ofd.data 为程序解析结果
pdf_bytes = ofd.to_pdf() # 转 pdf

ofd.del_data()

with open(r"增值税电子专票 5.pdf", "wb") as f:
    f.write(pdf_bytes)

异常
/Users/0x7o7/workspace/venv/work_script/bin/python3.11 /Users/0x7o7/workspace/sup/work_script/9-6script/main.py
2024-09-06 17:19:44.284 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simsun.ttc: 宋体
2024-09-06 17:19:44.284 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simsun.ttc: SWPMEH+SimSun
2024-09-06 17:19:44.284 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simsun.ttc: SimSun
2024-09-06 17:19:44.284 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simsun.ttc: SWDKON+SimSun
2024-09-06 17:19:44.284 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simkai.ttf: KaiTi
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simkai.ttf: 楷体
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simkai.ttf: SWLCQE+KaiTi
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simkai.ttf: SWHGME+KaiTi
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simkai.ttf: BWSimKai
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed STKAITI.TTF: STKAITI
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: Courier New
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: CourierNewPSMT
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: CourierNew
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: SWCRMF+CourierNewPSMT
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: SWANVV+CourierNewPSMT
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simhei.ttf: SimHei
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simhei.ttf: hei
2024-09-06 17:19:44.285 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed simhei.ttf: 黑体
Traceback (most recent call last):
File "/Users/0x7o7/workspace/sup/work_script/9-6script/main.py", line 29, in
ofd.read(ofdb64, save_xml=False, xml_name="testxml") # 读取 ofdb64
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/0x7o7/workspace/venv/work_script/lib/python3.11/site-packages/easyofd/ofd.py", line 46, in read
self.data = OFDParser(ofd_f)(save_xml=save_xml, xml_name=xml_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/0x7o7/workspace/venv/work_script/lib/python3.11/site-packages/easyofd/parser_ofd/ofd_parser.py", line 343, in call
return self.parser()
^^^^^^^^^^^^^
File "/Users/0x7o7/workspace/venv/work_script/lib/python3.11/site-packages/easyofd/parser_ofd/ofd_parser.py", line 231, in parser
signatures_info = SignaturesFileParser(signatures_xml_obj)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/0x7o7/workspace/venv/work_script/lib/python3.11/site-packages/easyofd/parser_ofd/file_parser.py", line 22, in init
assert xml_obj
AssertionError

@renoyuan
Copy link
Owner

renoyuan commented Sep 9, 2024

提供下 你的 python 版本 easyofd 版本 以及ofd 文件

@gomatthew
Copy link
Author

您好,

我的python版本是3.11.7
easyofd是0.3.6

@gomatthew
Copy link
Author

系统是mac os, M1芯片

@gomatthew
Copy link
Author

ofd文件邮箱已发

@renoyuan
Copy link
Owner

ofd文件邮箱已发

没收到,你确认下

@gomatthew
Copy link
Author

重发了,您看看

@gomatthew
Copy link
Author

gomatthew commented Sep 11, 2024 via email

@gomatthew
Copy link
Author

renoyuan@foxmail.com 您看下

@renoyuan
Copy link
Owner

拉新版本

@gomatthew
Copy link
Author

gomatthew commented Sep 12, 2024 via email

@renoyuan
Copy link
Owner

https://github.com/renoyuan/easyofd/wiki/FAQ
字体问题看FAQ

@junceo
Copy link

junceo commented Oct 10, 2024

楼主解决了吗?我也是mac 也遇到这个问题,有几个字体找不到

2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed STKAITI.TTF: STKAITI
2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: Courier New
2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: CourierNewPSMT
2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: CourierNew
2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: SWCRMF+CourierNewPSMT
2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed COURI.TTF: SWANVV+CourierNewPSMT

@renoyuan
Copy link
Owner

没得mac啊😢

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

3 participants