繁体   English   中英

如何将线模型控制命令发送到Zebra打印机?

[英]How do I send a Line Model control command to a Zebra printer?

我有以下代码,在将打印机置于行模式后发送,但在吞下[ESC]A后仅打印“ 51”

更改字体的命令是[ESC]A51

var hexValue = "1B"; // ESC char in HEX
var asciiValue = System.Convert.ToChar(System.Convert.ToUInt32(hexValue, 16));
var stringVal = new string(new char[] { asciiValue });
stringVal = stringVal + "A51"; // Smaller Font

data = Encoding.Default.GetBytes(stringVal + NewLine);

connection.Write(data);

需要一些正确的代码以规范输出到打印机。

var stringVal = new string(new char[] { System.Convert.ToChar(0x1b) /* ESC */, 
                                        'A', 
                                        System.Convert.ToChar(51) });
data = Encoding.Default.GetBytes(stringVal + NewLine);

connection.Write(data);

编辑

在这种情况下, A51需要引起注意。 如果51是使用'5', '1'或char使用System.Convert.ToChar(51)字符串,则该命令的传递方式是不同的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM