MROer万邦工业-工业标签标识打印机/碳带/软件一站式供应商

×
首页 > 服务与支持 > 斑马条码打印机(ZPL)如何通过TCP/IP发送ZPL指令?(C#与VB.net)

斑马条码打印机(ZPL)如何通过TCP/IP发送ZPL指令?(C#与VB.net)

斑马条码打印机(ZPL打印机:110Xi4 , 140Xi4 , 170Xi4 , 220Xi4 , R110Xi , R110Xi HF , R170Xi , 110XiIIIPlus , 140XiIIIPlus , 170XiIIIPlus , 220XiIIIPlus , 105SL , S4M , ZM400 , ZM600 , RZ400 , RZ600 , GX420t , GX420d , GX430t , GK420t , GK420d , RW 220 , RW 420 , RW 420 Print Station , 110PAX4 , 170PAX4 , R110PAX4 , C# , R110Xi4 , QLn 220 , QLn 320
)如何通过以太网接口TCP/IP发送ZPL指令到条码打印机呢?
 
 
下面通过C#与VB.net中的例子来进行说明:
1、C#中的例子
// Printer IP Address and communication port
string ipAddress = "10.3.14.42";
int port = 9100;
 
// ZPL Command(s)
string ZPLString =
    "^XA" +
    "^FO50,50" +
    "^A0N50,50" +
    "^FDHello, World!^FS" +
    "^XZ";
 
try
{
    // Open connection
    System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
    client.Connect(ipAddress, port);
 
    // Write ZPL String to connection
    System.IO.StreamWriter writer =
new System.IO.StreamWriter(client.GetStream());
    writer.Write(ZPLString);
    writer.Flush();
 
    // Close Connection
    writer.Close();
    client.Close();
}
catch (Exception ex)
{
    // Catch Exception
}
 
2、VB.net中的例子:
Dim ipAddress As String = "10.3.14.59"
Dim port As Integer = 9100
 
Dim ZPLString As String = _
"^XA" & _
      "^FO50,50" & _
      "^A0N,50,50" & _
      "^FDHello, World!^FS" & _
      "^XZ"
 
Try
      'Open Connection
      Dim client As New System.Net.Sockets.TcpClient
      client.Connect(ipAddress, port)
 
      'Write ZPL String to Connection
      Dim writer As New System.IO.StreamWriter(client.GetStream())
      writer.Write(ZPLString)
      writer.Flush()
 
      'Close Connection
      writer.Close()
      client.Close()
 
Catch ex As Exception
 
      'Catch Exception Here
 
End Try
 
 
 
<a href="http://www.mroer.com/Productmain_01.shtml">条码打印机</a>
<a href="http://www.mroer.com/Productmain_02.shtml">条码扫描器</a>
<a href="http://www.mroer.com/Productmain_03.shtml">数据采集器</a>
 
« 返回列表
博尔杰PTS|博尔杰标识商城|博盾安全标识|博锐迪生物标签