I figured out how to print basic text to our POS printer, but I can\'t figure out how to get the escape characters to work (for bold, text alignment, etc). For now I\'m just tes
From my testing I think the printer simulator will not accept the ESC character.
I create the text to send to the printer using a number of constant substitutes like:
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}|75P", ((char)27));
string escReset = String.Format("{0}|N", ((char)27));
string escUnderlineOn = String.Format("{0}|uC", ((char)27));
so I might send the following to the printer:
String.Format("{0}Hellow world!", escAlignCenter)"
To avoid getting the error when using the printer simulator I need to do the following
if(useSimulator)
{
string xxx = String.Format("{0}", ((char)27));
string testString = testPrint.ToString();
testString = testString.Replace(xxx, "\\");
logger.Debug("text to print is [{0}]", testString);
posPrinter.PrintNormal(PrinterStation.Receipt, testString);
}
else
posPrinter.PrintNormal(PrinterStation.Receipt, testPrint.ToString());
That removes the error however the text printed to the simulator includes all the ESC formatting.