Reputation: 11
I have a Zebra printer ZT230 and I am having a problem with positioning the labels. On the first print, the labels are positioned correctly, but on the second and third prints, the barcodes and text are no longer aligned correctly and move down.Trying to show the 4 barcodes with the incremented value on each label.
I Have this code :
static void Main(string[] args)
{
Console.WriteLine("Print: press Y");
Console.WriteLine("Close application: press ESC");
while (true)
{
var key = Console.ReadKey().Key;
if (key == ConsoleKey.Escape)
{
break;
}
else if (key == ConsoleKey.Y)
{
Console.WriteLine("Incrementing barcodes:");
Console.WriteLine("Enter the initial value for the barcode:");
string valueCode = Console.ReadLine();
Console.WriteLine("Enter the final value of the barcodes:");
string endCode = Console.ReadLine();
//Print(valueCode);
if(int.TryParse(valueCode,out int start) && int.TryParse(endCode,out int end))
{
for(int value = start; value <= end; value++)
{
Print(value.ToString());
}
}
else
{
Console.WriteLine("The entered values are not valid, please enter whole numbers");
}
}
Console.ReadLine();
}
Console.ReadLine();
}
private static void Print(string valueCode)
{
Console.WriteLine("Printing ...");
var ipPrinter = "xxxxxxxxxxx";
int port = xxxxx;
string zpl = string.Empty;
zpl = @"CT~~CD,~CC^~CT~^XA^PW406";
// Larger barcode and the value below it
zpl += @"^BY3,2,290^FO70,1020^BC^FD" + valueCode + "^FS";
The first barcode
zpl += @"^BY2,2,50^FO50,150^BC^FD" + valueCode + "^FS";
// The second barcode
zpl += @"^BY2,2,50^FO50,230^BC^FD" + valueCode + "^FS";
// The third barcode
zpl += @"^BY2,2,50^FO50,300^BC^FD" + valueCode + "^FS";
zpl += @"^PQ1,0,1,Y^XZ";
try
{
TcpClient client = new TcpClient();
client.Connect(ipPrinter, port);
StreamWriter writer = new StreamWriter(client.GetStream());
try
{
writer.Write(zpl);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
writer.Flush();
writer.Close();
client.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
Console.WriteLine("Data was printed!");
}
}
}
}
What I've tried so far:
I manually calibrated the printer from its menu. I used the Zebra Setup Utilities for automatic calibration. I adjusted the media feed and page length settings. I mention the length of my label is 45 cm and with a thickness of 5 cm. Thanks, if you can help me it would be great
The 3 smaller barcodes should be the ones on the label and the big code should be somewhere after the middle of it, I tried calibrating the printer and changing the dimensions in the code or setting the page length to 45 in the C# code, but when it keeps leaving me a blank page.
Upvotes: 1
Views: 134