我有一个 MVC Web 应用程序,我需要使用 ZPL 语言在 Zebra GK420t 标签打印机上打印各种标签。我们在不同的房间有几台打印机,一些打印机使用纵向标签,而另一些打印机使用横向标签。
有谁知道,是否有办法将当前加载的标签的尺寸从给定打印机读取到我的 c# 应用程序?然后应用程序可以根据不同的标签尺寸调整打印布局。
谢谢!
import requests
try:
url = 'http://'+ip+'/config.html'
print('going to access config page for ', url)
headers = {}
newdata = {}
response = requests.get(url, data=newdata, headers=headers)
# Find the position of the words 'LABEL LENGTH'
pos = response.text.find('LABEL LENGTH')
# get whatever text is 20 characters before that position,
# grab 6 characters of that, strip off any spaces and convert
# it to an integer. Thats your length.
lab_len = int(response.text[pos-20: pos-14].strip())
print('label length:', lab_len, type(lab_len))
except Exception as e:
print('print_zebra_label Exception accessing config ',e)
print('url attempted', url)
return False