以下是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:
不幸的是我没有合适的收据打印机来测试它,但我怀疑只有内置的热敏打印机模拟器才会出现错误。
请有人确认我的怀疑。
答案 0 :(得分:0)
在检查SDK示例之后,显然在发送到模拟器之前删除了控制代码,因此模拟器似乎不会模拟BOLD等。