Use this class to print receipts on a printer using a receipt printing language.
System.Object
Honeywell.AIDC.CrossPlatform.Print.Printer
Honeywell.AIDC.CrossPlatform.Print.LinePrinter
public sealed class LinePrinter : Printer;
The methods of this class must be called from a separate thread in order not to block the UI thread during lengthy printing operations. To print a receipt, you must define the printer commands and attributes used to communicate with the printer. This SDK provides a printer_profiles.JSON file with standard printer settings. You may use or modify the P6824, PR2, PR3, PB21, PB31, PB42 or PB51 settings defined in the “PRINTERS” object of printer_profiles.JSON for receipt printing. For more information, please refer to the Command and Attribute Format section of the Printer Commands and Attributes User Guide.
The following is the sample code snippet that demonstrates calling the LinePrinter API to print a receipt. The profiles parameter contains the contents of printer_profiles.JSON provided in the SDK.
using Honeywell.AIDC.CrossPlatform.Print; public async Task<String> DoPrint(string profiles) { string ret = await Task<string>.Run(() => { string result = string.Empty; LinePrinter linePrinter = null; try { linePrinter = new LinePrinter(profiles, "PB21", "bt:// 00:06:66:0A:B3:5D"); linePrinter.Connect(); // Set font style to Bold. linePrinter.Bold = true; linePrinter.Write("SALES ORDER"); // Turns off the Bold font style. linePrinter.Bold = false; linePrinter.NewLine(2); // The following text shall be printed in Normal font style. linePrinter.Write(" PRD. DESCRIPT. PRC. QTY. NET."); linePrinter.NewLine(2); linePrinter.WriteLine(" 1501 Timer-Md1 13.15 1 13.15"); linePrinter.WriteLine(" 1502 Timer-Md2 13.15 3 39.45"); linePrinter.WriteLine(" 1503 Timer-Md3 13.15 2 26.30"); linePrinter.WriteLine(" 1504 Timer-Md4 13.15 4 52.60"); linePrinter.WriteLine(" 1505 Timer-Md5 13.15 5 65.75"); linePrinter.WriteLine(" ---- ------"); linePrinter.Write(" SUBTOTAL 15 197.25"); linePrinter.NewLine(2); linePrinter.Write(" 5% State Tax 9.86"); linePrinter.NewLine(2); linePrinter.WriteLine(" ------"); linePrinter.Write(" BALANCE DUE 207.11"); linePrinter.NewLine(2); result = "Done printing."; } catch (Exception ex) { result = "DoPrint exception: " + ex.Message; } finally { if (null != linePrinter) { linePrinter.Disconnect(); linePrinter.Dispose(); } } return result; }); return ret; }