ZPL

来源:互联网 发布:民国公元纪年法的算法 编辑:程序博客网 时间:2024/06/01 09:45

Purpose

This sample code demonstrates how to open up a raw socket connection to a network ZPL printer and send a label down for printing.  It was written in C# using Visual Studio 2008 Professional and tested successfully on a Windows XP Machine Service Pack 3.

Sample Code

// 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
}

//打印二维码

QR Code https://km.zebra.com/kb/index?page=content&id=SA315&actp=LIST

string ZPLString =^XA^FO100,100^BQN,2,10^FDYourTextHere^FS^XZ
 
 
 
 

0 0
原创粉丝点击