Files
test/zpl_print/models/common.py
2024-03-14 14:24:26 +08:00

35 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
import ctypes
from odoo import models
class Common(models.Model):
_name = 'sf.sync.common'
_description = u'公用类'
def print_zpl(self, zpl_str):
# WinDll_path = "D://桌面//pythonZPL//tsc_python_sdk_example//TSC_Python_SDK_Example//tsc_sample//libs//TSCLIB.dll"
WinDll_path = "D://jikimo-dev//jikimo//SF//zpl_print//libs//TSCLIB.dll"
# WinDll_path = "D://桌面//pythonZPL//zebra_zpl//libs//TSCLIB.dll"
try:
tsclibrary = ctypes.WinDLL(WinDll_path)
tsclibrary.openportW("USB")
print(type(zpl_str))
print(zpl_str)
original_string = "^XA\n^FO100,50\n^A0N,44,33^FD[PO-2023-1226-0215-1] P-S00001-1^FS\n^FO100,100\n^A0N,44,33^FDLN/SN: P-S00001-1-12348啊a^FS\n^FO100,150^BY3\n^BCN,100,Y,N,N\n^FDP-S00001-1-12348啊a^FS\n^XZ"
# 使用加号操作符
new_string = original_string + "^CW1,E:SIMSUN.FNT #绑定字体\n^CI28 #UTF-8编码"
# 使用字符串格式化方法
new_string = "{}^CW1,E:SIMSUN.FNT #绑定字体\n^CI28 #UTF-8编码".format(original_string)
print(new_string)
tsclibrary.sendcommandW(new_string)
print('111222')
tsclibrary.printlabelW("0", "1")
tsclibrary.closeport()
except Exception as e:
raise UserWarning("错误警告:%s" % e)