Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions easyofd/draw/draw_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def draw_chars(self, canvas, text_list, fonts, page_size):
try:
c.setFont(font, line_dict["size"] * self.OP)
except KeyError as key_error:
logger.error(f"{key_error}")
logger.error(f"font({font}) not found: {key_error}")
font = self.font_tool.FONTS[0]
c.setFont(font, line_dict["size"] * self.OP)
# 原点在页面的左下角
Expand Down Expand Up @@ -654,7 +654,7 @@ def draw_pdf(self):
file_name = font_v.get("FontFile")
font_b64 = font_v.get("font_b64")
if font_b64:
self.font_tool.register_font(os.path.split(file_name)[1], font_v.get("@FontName"), font_b64)
self.font_tool.register_font(os.path.split(file_name)[1], font_v.get("FontName"), font_b64)
# text_write = []
# print("doc.get(page_info)", len(doc.get("page_info")))
for page_id, page in doc.get("page_info").items():
Expand Down
1 change: 1 addition & 0 deletions easyofd/draw/font_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def register_font(self,file_name,FontName,font_b64):
# print("FontName", FontName, "file_name", file_name)
pdfmetrics.registerFont(TTFont(FontName, file_name))
self.FONTS.append(FontName)
logger.debug(f"FontTool.register_font success, name={FontName}, file={file_name}")
except Exception as e:
logger.error(f"register_font_error:\n{e} \n 包含不支持解析字体格式")
finally:
Expand Down
4 changes: 2 additions & 2 deletions easyofd/parser_ofd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
for name in names:
try:
pdfmetrics.registerFont(TTFont(name, font))
except:
logger.warning(f"FONT registerFont failed {font}: {name}")
except Exception as e:
logger.warning(f"FONT registerFont failed '{font}'({name}): {e}")

from easyofd.parser_ofd.ofd_parser import OFDParser
__all__=["OFDParser"]
Expand Down
3 changes: 2 additions & 1 deletion easyofd/parser_ofd/file_annotation_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# NOTE: 注释解析
from loguru import logger
from .file_parser_base import FileParserBase
from .file_publicres_parser import PublicResFileParser

class AnnotationsParser(FileParserBase):
"""
Expand Down Expand Up @@ -36,7 +37,7 @@ def __call__(self):
}

return info
class AnnotationFileParser(FileParserBase):
class AnnotationFileParser(PublicResFileParser):
"""
Parser Annotation
注释类 包含 签名注释 水印注释 信息注释
Expand Down