I'm using Zebra printer model ZQ520 and connecting to it through application in C#.
string zpl = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";
try
{
connection.Open();
string setLang = "! U1 setvar \"device.languages\" \"zpl\"\r\n";
string calibrate = "~jc^xa^jus^xz\r\n";
connection.Write(Encoding.UTF8.GetBytes(setLang));
connection.Write(Encoding.UTF8.GetBytes(calibrate));
connection.Write(Encoding.UTF8.GetBytes(zpl));
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine("Exception:" + e.Message);
}
The issue is the printer is printing out an excessive amount of paper. It doesn't print "This is a ZPL test." until I press the line feed button on the printer, and then it printer more excess paper after the desired message.
Any idea what issue might be?
Have you checked the ^LL (Label Length) command. Look it up in your Zebra Programming Language guide.
I also know when I was doing Zebra (and also Intermec), the device itself had machine settings / display using buttons and arrows to change such default settings as page sizes, if thermal, what burn strength 0-30, etc., so you did not have to invoke those on every label submit.
I was also communicating directly with serial port using USB to RS232 connector cable, but it has been a while.
You may try to use the following code to communicate with the printer:
using (var tcpClient = new TcpClient())
{
try
{
var ipAddress = "127.0.0.1";
var printerPort = 9001;
tcpClient.Connect(ipAddress, printerPort);
using (var tcpClientStream = new StreamWriter(tcpClient.GetStream()))
{
var deviceLang = "! U1 setvar \"device.languages\" \"zpl\"\r\n");
tcpClientStream.Write(deviceLang );
tcpClientStream.Flush();
var calibrate = "~jc^xa^jus^xz";
tcpClientStream.Write(calibrate);
tcpClientStream.Flush();
Thread.Sleep(500);
string zpl = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";
// with ^LL: string zpl = "^XA^LL400^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";
tcpClientStream.Write(zpl);
tcpClientStream.Flush();
tcpClientStream.Close();
}
tcpClient.Close();
}
catch (Exception ex)
{
Logger.Error(ex); // replace with your own logger or console
}
}
This should print the expected text immediately. Other than that, for continuous media (ie no gaps). I'm not familiar with this particular model but according to this:
You need to send the following command: . U1 setvar "media.type" "journal"
. U1 setvar "media.type" "journal"
then set the label length somehow, for example ^LL400
. Also you may try to comment the deviceLang and calibrate commands, not 100% sure those are really required (on the ZT610 they're definitely not, as you can calibrate the printer using buttons).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.