-
Notifications
You must be signed in to change notification settings - Fork 34
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
Comments
提供下 你的 python 版本 easyofd 版本 以及ofd 文件 |
您好, 我的python版本是3.11.7 |
系统是mac os, M1芯片 |
ofd文件邮箱已发 |
没收到,你确认下 |
重发了,您看看 |
ofd文件见附件
在 2024-09-09 10:35:24,"貌似大家" ***@***.***> 写道:
提供下 你的 python 版本 easyofd 版本 以及ofd 文件
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
拉新版本 |
saving xml Content.xml
2024-09-12 10:56:48.784 | INFO | easyofd.ofd:to_pdf:72 - to_pdf
page_size_details [[0.0, 0.0, 210.0, 140.0]]
2024-09-12 10:56:48.940 | ERROR | easyofd.draw.draw_pdf:__call__:468 - '楷体'
2024-09-12 10:56:48.940 | ERROR | easyofd.draw.draw_pdf:__call__:469 - ofd解析失败
Traceback (most recent call last):
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 697, in getFont
return _fonts[fontName]
~~~~~~^^^^^^^^^^
KeyError: '楷体'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/install/anaconda3/lib/python3.11/site-packages/easyofd/draw/draw_pdf.py", line 465, in __call__
self.draw_pdf()
File "/data/install/anaconda3/lib/python3.11/site-packages/easyofd/draw/draw_pdf.py", line 443, in draw_pdf
self.draw_chars(c, text_list, fonts, page_size)
File "/data/install/anaconda3/lib/python3.11/site-packages/easyofd/draw/draw_pdf.py", line 145, in draw_chars
c.setFont(font, line_dict["size"] * self.OP)
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfgen/canvas.py", line 1738, in setFont
font = pdfmetrics.getFont(self._fontname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 699, in getFont
return findFontAndRegister(fontName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 681, in findFontAndRegister
face = getTypeFace(fontName)
^^^^^^^^^^^^^^^^^^^^^
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 638, in getTypeFace
return _typefaces[faceName]
~~~~~~~~~~^^^^^^^^^^
KeyError: '楷体'
Traceback (most recent call last):
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 697, in getFont
return _fonts[fontName]
~~~~~~^^^^^^^^^^
KeyError: '楷体'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/install/anaconda3/lib/python3.11/site-packages/easyofd/draw/draw_pdf.py", line 465, in __call__
self.draw_pdf()
File "/data/install/anaconda3/lib/python3.11/site-packages/easyofd/draw/draw_pdf.py", line 443, in draw_pdf
self.draw_chars(c, text_list, fonts, page_size)
File "/data/install/anaconda3/lib/python3.11/site-packages/easyofd/draw/draw_pdf.py", line 145, in draw_chars
c.setFont(font, line_dict["size"] * self.OP)
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfgen/canvas.py", line 1738, in setFont
font = pdfmetrics.getFont(self._fontname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 699, in getFont
return findFontAndRegister(fontName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 681, in findFontAndRegister
face = getTypeFace(fontName)
^^^^^^^^^^^^^^^^^^^^^
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 638, in getTypeFace
return _typefaces[faceName]
~~~~~~~~~~^^^^^^^^^^
KeyError: '楷体'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/install/anaconda3/lib/python3.11/site-packages/reportlab/pdfbase/pdfmetrics.py", line 697, in getFont
return _fonts[fontName]
~~~~~~^^^^^^^^^^
KeyError: '宋体'
您看下
在 2024-09-11 17:46:04,"貌似大家" ***@***.***> 写道:
拉新版本
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
楼主解决了吗?我也是mac 也遇到这个问题,有几个字体找不到 2024-10-10 16:33:40.728 | WARNING | easyofd.parser_ofd::24 - FONT registerFont failed STKAITI.TTF: STKAITI |
没得mac啊😢 |
代码
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
异常
/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
The text was updated successfully, but these errors were encountered: