I have an Epson TM-T88VI printer and use the Microsoft.PointOfService.PosPrinter in C# for printing.
I have the following two test functions:
public static void printerTestFunction(string printerName)
{
PosExplorer explorer = new PosExplorer();
DeviceInfo di = explorer.GetDevice("PosPrinter", printerName);
PosPrinter printer = (PosPrinter)explorer.CreateInstance(di);
printer.Open();
printer.Claim(10000);
printer.DeviceEnabled = true;
printer.AsyncMode = false;
string init = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 64 });
string totalCut = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 105 });
string cmd = init + "A€A\nB€B\n\n\n\n\n\n\n\n" + totalCut;
printer.PrintNormal(PrinterStation.Receipt, cmd);
}
public static void printerTestFunction2(string printerName)
{
PosExplorer explorer = new PosExplorer();
DeviceInfo di = explorer.GetDevice("PosPrinter", printerName);
PosPrinter printer = (PosPrinter)explorer.CreateInstance(di);
printer.Open();
printer.Claim(10000);
printer.DeviceEnabled = true;
printer.AsyncMode = false;
string init = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 64 });
string totalCut = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 105 });
string cmd = init + init + "A€A\nB€B\n\n\n\n\n\n\n\n" + totalCut;
printer.PrintNormal(PrinterStation.Receipt, cmd);
}
The only difference between the two functions: in function2 i send a "double" init to the printer (see string cmd =
initialization).
Normally I would expect the two functions to lead to the same result. But that is not the case.
After calling "printerTestFunction2" i get the output as expected:
A€A
B€B
When i restart my program and call "printerTestFunction" i get the following output:
t@A€A
B€B
I also tested with other functions. The first init command is always printed as "t@" except if I init the printer twice.
Can somebody explain that behaviour?
This is because, as I answered the previous question, the application is sending the initialization command directly.
Why is the “€” character only printed before printer initialization and not after the initialization?
If you are using POS for.NET (including OPOS/JavaPOS), you should not use the initialization command (ESC@) or similar commands to change the mode or settings.
If you want to do something, call the method or put the POSPrinter escape sequence defined in UnifiedPOS into the print request string.