条码打印四 - 4.C#Zebra斑马便携式打印机Wifi TCP打印

删除回忆录丶 提交于 2020-01-09 11:17:27
 1 // Printer IP Address and communication port
 2 string ipAddress = "10.3.14.42";
 3 int port = 9100;
 4  
 5 // ZPL Command(s)
 6 string ZPLString =
 7     "^XA" +
 8     "^FO50,50" +
 9     "^A0N50,50" +
10     "^FDHello, World!^FS" +
11     "^XZ";
12  
13 try
14 {
15     // Open connection
16     System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
17     client.Connect(ipAddress, port);
18  
19     // Write ZPL String to connection
20     System.IO.StreamWriter writer =
21 new System.IO.StreamWriter(client.GetStream());
22     writer.Write(ZPLString);
23     writer.Flush();
24  
25     // Close Connection
26     writer.Close();
27     client.Close();
28 }
29 catch (Exception ex)
30 {
31     // Catch Exception
32 }

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!