/// <summary> /// Method to print the raw bytes of a BMP-formatted image. /// </summary> /// <param name="image">Image bytes to print.</param> private void PrintLogoBytes(byte[] image) { if (this.oposPrinter.CapRecBitmap) { if (null != image && image.Length > 0) { int conversion = this.oposPrinter.BinaryConversion; // save current conversion mode this.oposPrinter.BinaryConversion = 2; // OposBcDecimal this.oposPrinter.PrintMemoryBitmap( (int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, OposHelper.ConvertToBCD(image), (int)OPOSPOSPrinterConstants.PTR_BMT_BMP, (int)OPOSPOSPrinterConstants.PTR_BM_ASIS, (int)OPOSPOSPrinterConstants.PTR_BM_CENTER); this.oposPrinter.BinaryConversion = conversion; // restore previous conversion mode } } }
/// <summary> /// Print the text to the Printer. /// </summary> /// <param name="textToPrint">The text to print on the receipt.</param> private void PrintText(string textToPrint) { Match barCodeMarkerMatch = Regex.Match(textToPrint, BarCodeRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase); bool printBarcode = false; string receiptId = string.Empty; if (barCodeMarkerMatch.Success) { printBarcode = true; // Get the receiptId receiptId = barCodeMarkerMatch.Groups[1].ToString(); // Delete the barcode marker from the printed string textToPrint = textToPrint.Remove(barCodeMarkerMatch.Index, barCodeMarkerMatch.Length); } // replace ESC with Char(27) and add a CRLF to the end textToPrint = textToPrint.Replace("ESC", ((char)27).ToString()); if (this.binaryConversionEnabled == true) { this.oposPrinter.BinaryConversion = 2; // OposBcDecimal textToPrint = OposHelper.ConvertToBCD(textToPrint + "\r\n\r\n\r\n", this.oposPrinter.CharacterSet); } this.oposPrinter.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, textToPrint); this.oposPrinter.BinaryConversion = 0; // OposBcNone // Check if we should print the receipt id as a barcode on the receipt if (printBarcode == true) { this.oposPrinter.PrintBarCode( (int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, receiptId, (int)OPOSPOSPrinterConstants.PTR_BCS_Code128, 80, 80, (int)OPOSPOSPrinterConstants.PTR_BC_CENTER, (int)OPOSPOSPrinterConstants.PTR_BC_TEXT_BELOW); this.oposPrinter.PrintNormal((int)OPOSPOSPrinterConstants.PTR_S_RECEIPT, "\r\n\r\n\r\n\r\n"); } }
/// <summary> /// Displays the text. /// </summary> /// <param name="lines">The lines to display.</param> public void DisplayText(IEnumerable <string> lines) { ThrowIf.Null(lines, "lines"); this.oposLineDisplayWorker.Execute((oposLineDisplay) => { var index = 0; foreach (var line in lines) { var textToDisplay = line; if (this.binaryConversionEnabled) { oposLineDisplay.BinaryConversion = 2; // OposBcDecimal textToDisplay = OposHelper.ConvertToBCD(textToDisplay, oposLineDisplay.CharacterSet); } oposLineDisplay.DisplayTextAt(index++, 0, textToDisplay, (int)OPOSLineDisplayConstants.DISP_DT_NORMAL); oposLineDisplay.BinaryConversion = 0; // OposBcNone } }); }