以下是 Micrsoft.PointOfService 打印机的 ESC 代码:
string escAlignCenter = String.Format("{0}|cA", ((char)27));
string escAlignRight = String.Format("{0}|rA", ((char)27));
string escBoldOn = String.Format("{0}|bC", ((char)27));
string escNewLine = String.Format("{0}|1lF", ((char)27));
string escPaperCut = String.Format("{0}{1}|P", ((char)27), AppSettings.POSPrinterLinesToCut);
string escReset = String.Format("{0}|N", ((char)27));
string escUnderlineOn = String.Format("{0}|uC", ((char)27));
这段代码
simulatedReceipt.AppendLine(string.Format("{0}{1}Header will appear Here{2}", escBoldOn, escAlignCenter, escReset));
当发送到模拟器打印机时
textToPrint = simulatedReceipt.ToString();
posPrinter.PrintNormal(PrinterStation.Receipt, textToPrint);
结果是:
System.FormatException occurred
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at Microsoft.PointOfService.DeviceSimulators.PosPrinterSimulatorWindow.ProcessEscapes(String str)
at Microsoft.PointOfService.DeviceSimulators.PosPrinterSimulatorWindow.DisplayText(String str)
at Microsoft.PointOfService.DeviceSimulators.PosPrinterSimulator.PrintNormalImpl(PrinterStation station, PrinterState printerState, String data)
at Microsoft.PointOfService.BaseServiceObjects.PosPrinterBase.OutputRequestHandler(OutputRequest Request)
at Microsoft.PointOfService.Internal.PosCommonInternal.ProcessOutputRequest(OutputRequest request, Boolean asyncOperation)
at MyCourts.PrintReceiptManager.printToPOSPrinter() in e:\MyCourts\MyCourts\Managers\PrintReceiptManager.cs:line 558
InnerException:
不幸的是,我没有合适的收据打印机来测试它,但我怀疑这个错误只发生在内置的热敏打印机模拟器上。
谁能证实我的怀疑。