Just stared getting this error after updating to Zebra.Printer.SDK v2.15.2634 from 2.14.1989
C# sample code
string conn = null;
foreach (DiscoveredPrinterDriver zPrinter in UsbDiscoverer.GetZebraDriverPrinters()) { conn = zPrinter.GetConnection().ToString(); }
if ( Sys.PartNumberModel.CompanyName == "Hi") { PrinterUtil.SendContents(conn, "^XA");
2 Replies
Hello Bret,
Seems you are using a wrong method to print your label. As you can see in PrinterUtil Class usage example the SendContents is intended to store some data on printer as a file. It is not intended to be used to print ZPL content.
Instead of that, you need to use UsbConnection.Write method. Please, use code from TcpConnection Class as an example. You will need to use UsbConnection instead of TcpConnection. In a nutshell you will need to perform following steps:
1) UsbConnection conn = zPrinter.GetConnection();2) conn.Open();3) conn.Write(Encoding.UTF8.GetBytes("..your ZPL code goes here.."));
4) conn.Close();
Don't forget to use try-catch statements to handle possible exceptions.
Hope it help.
Dmitry Prokhorov
Software Engineer, Kutir Mobility
Posted on behalf of Zebra Technologies
Hello Bret,
Could you pls to perform a check if it will work in case you will join all your strings into one string and send this string to PrinterUtil.SendContents method in a single call?
In case it will continue suffering from issue then seems you'll need to submit your problem to Zebra Technical Support.
Dmitry Prokhorov
Software Engineer, Kutir Mobility
Posted on behalf of Zebra Technologies