public PrinterStatus getPrinterStatus(rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType connType, string address, Int32 port) { Logger.Write("MainWindow.getPrinterStatus call, address=" + address + " port=" + port.ToString()); PrinterStatus status = null; ZebraPrinterConnection connection = null; ZebraPrinter printer = null; if (connType == rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType.eTCP) { connection = new TcpPrinterConnection(address, port); } else if (connType == rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType.eBluetooth) { connection = new BluetoothPrinterConnection(address); } else if (connType == rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType.eUSB) { connection = new UsbPrinterConnection(address); } else { Logger.Write("MainWindow.getPrinterStatus undifined connection type"); return null; } connection.Open(); if (connection.IsConnected()) { printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, connection); status = printer.GetCurrentStatus(); } connection.Close(); Logger.Write("MainWindow.getPrinterStatus call finished"); return status; }
public PrinterStatus getPrinterStatus(rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType connType, string address, Int32 port) { Logger.Write("MainWindow.getPrinterStatus call, address=" + address + " port=" + port.ToString()); PrinterStatus status = null; ZebraPrinterConnection connection = null; ZebraPrinter printer = null; if (connType == rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType.eTCP) { connection = new TcpPrinterConnection(address, port); } else if (connType == rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType.eBluetooth) { connection = new BluetoothPrinterConnection(address); } else if (connType == rho.PrinterZebraImpl.PrinterZebra.EPrinterConnectionType.eUSB) { connection = new UsbPrinterConnection(address); } else { Logger.Write("MainWindow.getPrinterStatus undifined connection type"); return(null); } connection.Open(); if (connection.IsConnected()) { printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, connection); status = printer.GetCurrentStatus(); } connection.Close(); Logger.Write("MainWindow.getPrinterStatus call finished"); return(status); }
void acPrinterTest(NSObject sender) { CGPDFDocument pdfDoc = CGPDFDocument.FromFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "100605 PrePlumbingPDF_Signed.pdf")); UIImage img = MyConstants.ImageFromPDF(pdfDoc, 1); TcpPrinterConnection myConn; myConn = new TcpPrinterConnection("10.11.1.3", 6101, 10, 10); NSError err; bool connectionOK = myConn.Open(); if (connectionOK) { try { // string test = SGD.Get ("appl.name", myConn, out err); // -- SGD class from Zebra API works ZebraPrinterCpcl zprn = ZebraPrinterFactory.GetInstance(myConn, PrinterLanguage.PRINTER_LANGUAGE_CPCL); GraphicsUtilCpcl gu = zprn.GetGraphicsUtil(); string testSETFF = "! U1 JOURNAL\r\n! U1 SETFF 50 5\r\n"; NSData testData = NSData.FromArray(System.Text.UTF8Encoding.UTF8.GetBytes(testSETFF)); myConn.Write(testData, out err); // gu.printImage(img.CGImage, 280, 5, -1, -1, false, out err); gu.printImage(img.CGImage, 280, 5, -1, -1, false, out err); if (err != null) { // Console.WriteLine (err.LocalizedDescription); } } finally { myConn.Close(); } } }
private void Run() { try { if (ConnectionType == PrinterZebra.EPrinterConnectionType.eTCP) { Connection = new TcpPrinterConnection(Address, Port, MaxTimeoutForRead, TimeToWaitForMoreData); } else if (ConnectionType == PrinterZebra.EPrinterConnectionType.eBluetooth) { Connection = new BluetoothPrinterConnection(Address, MaxTimeoutForRead, TimeToWaitForMoreData); } else if (ConnectionType == PrinterZebra.EPrinterConnectionType.eUSB) { Connection = new UsbPrinterConnection(Address); } if (Connection == null) { return; } Connection.Open(); if (Connection != null && !Connection.IsConnected()) { Close(); return; } if (Connection != null) { if (ConnectionType != PrinterZebra.EPrinterConnectionType.eUSB) { SGD.SET("device.languages", "ZPL", Connection); } else { //Do nothing for USB } Printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, Connection); if (ConnectionType != PrinterZebra.EPrinterConnectionType.eUSB) { FriendlyName = SGD.GET("device.friendly_name", Connection); } else { FriendlyName = "USB Printer"; } if (FriendlyName.Length == 0) { Logger.Write("friendly name is empty, return device name"); FriendlyName = Address; } } } catch (ZebraPrinterConnectionException e) { Logger.Write("Connect exception [connection]: " + e.Message); Close(); } catch (ZebraGeneralException e) { Logger.Write("Connect exception [general]: " + e.Message); Close(); } catch (Exception e) { Logger.Write("Connect exception [system]: " + e.Message); Close(); } }