public static void Print(string zpl) { //await Task.Run(() => //{ // DiscoveredPrinter discoveredPrinter = GetUSBPrinter(); // ZebraPrinter printer = PrintHelper.Connect(discoveredPrinter, PrinterLanguage.ZPL); // PrintHelper.SetPageLanguage(printer); // if (PrintHelper.CheckStatus(printer)) // { // PrintHelper.Print(printer, zpl); // if (PrintHelper.CheckStatusAfter(printer)) // { // Console.WriteLine($"Label Printed"); // } // } // printer = PrintHelper.Disconnect(printer); // Console.WriteLine("Done Printing"); //}); Connection thePrinterConn = null; try { var db = new IPConfigurationManager(); var ipAddress = db.GetIP(); // Instantiate connection for ZPL TCP port at given address thePrinterConn = ConnectionBuilder.Build($"TCP:{ipAddress}:9100"); // Open the connection - physical connection is established here. thePrinterConn.Open(); // This example prints "This is a ZPL test." near the top of the label. //string zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ"; // Send the data to printer as a byte array. thePrinterConn.Write(Encoding.UTF8.GetBytes(zpl)); } catch (ConnectionException e) { // Handle communications error here. Console.WriteLine(e.ToString()); } finally { // Close the connection to release resources. if (thePrinterConn != null) { thePrinterConn.Close(); } } }
public GreigeBarcodePage() { InitializeComponent(); _barcodes = new List <BarcodeInfo>(); pb.Visibility = Visibility.Hidden; EditButton.IsEnabled = true; TestButton.IsEnabled = false; SaveButton.IsEnabled = false; IPTextBox.IsReadOnly = true; _dbSQLite = new IPConfigurationManager(); IPTextBox.Text = _dbSQLite.GetIP(); IPTextBox.IsReadOnly = true; }