Problem printing labels on my Zebra ZD420

// Expert user has replied.
S Sinan Redzheb 2 years 9 months ago
40 1 0

Hello,
I have developed a test application for printing labels.
Sometimes it prints like a charm, sometimes it doesn't print anything and
just throws exceptions like "Malformed Multipart Form Data" and "Malformed status response - unable to determine printer status".
Can you please help me with these errors?
I am using the latest Zebra.SDK nuget package (2.15.2634), Firmware version is V84.20.22Z.
Here is my sample code:
ZPL Format :
ZPL_String = "^XA" +
"^DFE:FORMAT2.ZPL" +
"^FS" +
"^FT26,243^A0N,56,55^FH\\^FN12\"First Name\"^FS" +
"^FT26,296^A0N,56,55^FH\\^FN11\"Last Name\"^FS" +
"^FT258,73^A0N,39,38^FH\\^FDVisitor^FS" +
"^FO100,100^XG^FN13,1,1^FS" +
"^FO5,17^GB601,379,8^FS" +
"^XZ";
Variables for printing:
Dictionary variables = new Dictionary
{
{12,"Sinan" },
{11,"Redzheb" },
{13,"Something" }
};
public void Print(Dictionary variables)
{
Connection conn = new UsbConnection(_printer.Address); // DiscoveredUsbPrinter
try
{
conn.Open();
ZebraPrinter _genericPrinter = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, conn);
ZebraPrinterLinkOs _linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(_genericPrinter, PrinterLanguage.ZPL);
PrinterStatus printerStatus = _genericPrinter.GetCurrentStatus();
if (CanPrint(printerStatus) == false) return;
if (_linkOsPrinter != null)
{
//I have already successfully stored format on the printer
_linkOsPrinter.PrintStoredFormatWithVarGraphics("E:FORMAT2.ZPL", variables);
}
}
catch (ConnectionException ex)
{
ErrorLog = "***** ERROR " + ex.Message.ToString() + Environment.NewLine;
}
catch (ZebraPrinterLanguageUnknownException ex)
{
ErrorLog = "***** ERROR " + ex.Message.ToString() + Environment.NewLine;
}
finally
{
conn.Close();
}
}

Please register or login to post a reply

1 Replies

S Steven Si

For ZPL, each line of ZPL should be ended with carriage return and new line, i.e. "\r\n". I'd suggest to add "\r\n" to the end of each ZPL line. What is this line? The ^FN13 should not be used as parameter to ^XG. If you want to print the stored graphics, you can put the name of the image file directly after ^XG. 

"^FO100,100^XG^FN13,1,1^FS" + 

CONTACT
Can’t find what you’re looking for?