|
|
|
@@ -140,10 +140,16 @@ def _zpl_escape(s: str) -> str: |
|
|
|
return s.replace("\\", "\\\\").replace("^", "\\^") |
|
|
|
|
|
|
|
|
|
|
|
def generate_zpl_dataflex(batch_no: str, item_code: str, item_name: str) -> str: |
|
|
|
def generate_zpl_dataflex( |
|
|
|
batch_no: str, |
|
|
|
item_code: str, |
|
|
|
item_name: str, |
|
|
|
font_regular: str = "E:STXihei.ttf", |
|
|
|
font_bold: str = "E:STXihei.ttf", |
|
|
|
) -> str: |
|
|
|
""" |
|
|
|
Generate ZPL for DataFlex label (53 mm media, 90° rotated). |
|
|
|
Uses UTF-8 (^CI28) and fonts msjh.ttc / msjhbd.ttc for Chinese/English. |
|
|
|
Uses UTF-8 (^CI28) and configurable .TTF fonts for Chinese (e.g. E:STXihei.ttf). |
|
|
|
""" |
|
|
|
desc = _zpl_escape((item_name or "—").strip()) |
|
|
|
code = _zpl_escape((item_code or "—").strip()) |
|
|
|
@@ -154,11 +160,11 @@ def generate_zpl_dataflex(batch_no: str, item_code: str, item_name: str) -> str: |
|
|
|
^PO N |
|
|
|
^CI28 |
|
|
|
^FO70,70 |
|
|
|
^A@R,60,60,E:MSJH.TTC^FD{desc}^FS |
|
|
|
^A@R,60,60,{font_regular}^FD{desc}^FS |
|
|
|
^FO220,70 |
|
|
|
^A@R,50,50,E:MSJHBD.TTC^FD{code}^FS |
|
|
|
^A@R,50,50,{font_bold}^FD{code}^FS |
|
|
|
^FO310,70 |
|
|
|
^A@R,45,45,E:MSJHBD.TTC^FD批次: {batch}^FS |
|
|
|
^A@R,45,45,{font_bold}^FD批次: {batch}^FS |
|
|
|
^FO150,420 |
|
|
|
^BQN,2,6^FDQA,{batch_no}^FS |
|
|
|
^XZ""" |
|
|
|
|