ZC300 in Windows Forms

G Gerardo Morales 4 weeks ago
72 0 0

I want to print some card templates using code. I've tried copying the example code from the SDK documentation, but it just doesn't work.

Here's an example of the code I've tried. The code is supposed to print an image, but it doesn't.

//************************************************************************************************************

 public static void Main(string[] args)  {
           //This line is for connect to printer by local net
          //Connection connection = new TcpConnection("192.168.1.23", TcpConnection.DEFAULT_ZPL_TCP_PORT);          
          //This line is for connect to printer by USB
          //Connection connection = new UsbConnection(UsbDiscoverer.GetZebraUsbPrinters(new ZebraCardPrinterFilter())[0].ToString());
           try {
               connection.Open();
               ZebraPrinter printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, connection);
               int x = 0;  int y = 0;
               printer.PrintImage(@"C:\Users\Gerardo-Sistemas\Pictures\unnamed - Copy-Recovered.bmp", x, y);
           }
           catch (ConnectionException e) {
               Console.WriteLine(e.ToString());
           }
           catch (ZebraPrinterLanguageUnknownException e)   {
               Console.WriteLine(e.ToString());
           }
           catch (IOException e)   {
               Console.WriteLine(e.ToString());
           }
           finally  {
               connection.Close();
           }
           Console.ReadLine();
       }

//**************************************************************************************************************

I know that the example code is for Console, but if I can make this single function work, I think I'll be able to proceed.

Perhaps, I have installed the Zebra.Printer.Card.SDK and Zebra.Printer.SDK libraries in the project. What am I doing wrong, or what else do I need to do?

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