certflow.services.printer.template_manager module¶
合格证模板管理器
加载和管理从 VBA 坐标转换而来的模板配置。 通过 cfg() 从主配置统一读取,不再独立加载 YAML 文件。
- class certflow.services.printer.template_manager.TemplateInfo[源代码]¶
基类:
TypedDict模板信息
- fields: dict[str, FieldPosition]¶
- class certflow.services.printer.template_manager.TemplateManager(config_path=None)[源代码]¶
基类:
object合格证模板管理器
负责加载和管理从 VBA 坐标转换而来的模板配置。 通过 cfg() 从主配置统一读取 template_coordinates 节点。
- 使用示例:
# 初始化管理器 tm = TemplateManager()
# 获取所有模板 templates = tm.get_all_templates()
# 获取指定模板 template = tm.get_template("russian")
# 获取模板中的字段坐标 pos = tm.get_field_position("russian", "product_name") print(f"产品名称位置: x={pos['x_mm']}mm, y={pos['y_mm']}mm")
- 参数:
config_path (str | None)
- get_template(template_key)[源代码]¶
获取指定模板
- 参数:
template_key (str) -- 模板键名(如 "russian", "full_chinese_1")
- 返回:
模板信息,不存在时返回 None
- 返回类型:
TemplateInfo | None
- get_field_position(template_key, field_name)[源代码]¶
获取模板中指定字段的位置
- 参数:
- 返回:
字段位置信息,不存在时返回 None
- 返回类型:
FieldPosition | None