Print and open drawer with Epson T20 (thermal printer)

uoah picture uoah · Dec 15, 2011 · Viewed 14.1k times · Source

I've searching a lot and I've found here examples with Posexplorer but my printer is usb and I've read that PosExplorer is for parallel. I don't know how to print with the printer and how to send the code to printer to open the drawer.

I'm using to send escape sequence to the printer the following code:

string ESC = Convert.ToString((char)27);
string logo=Convert.ToString(ESC+"|tL");
_oposPrinter.PrintNormal(PrinterStation.Receipt, logo);
_oposPrinter.PrintNormal(PrinterStation.Receipt, "Print example\n");
_oposPrinter.PrintNormal(PrinterStation.Receipt, Convert.ToString((char)27 + "|#fP"));

When debugging and reaches the lines:

_oposPrinter.PrintNormal(PrinterStation.Receipt, logo);

or

_oposPrinter.PrintNormal(PrinterStation.Receipt, Convert.ToString((char)27 + "|#fP"));

The printer doesn't prints anything.

Answer

Zyo picture Zyo · Apr 24, 2012

If you are looking to a very lightweight solution without having a 3rd party installed software such as Microsoft POS for .NET.

You need to include the function RawPrinterHelper (can be download from https://support.microsoft.com/en-us/help/322091/how-to-send-raw-data-to-a-printer-by-using-visual-c-.net)

Then send the specific cash drawer code to open it to the printer it's connected to.

For instance, on an Epson TM88, this function would open it.

SendStringToPrinter(printerName, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 112, 48, 55, 121 }));

Other printers may require other code sequences.

Citizen
27,112,0,50,250
Epson 
27,112,48,55,121
27,112,0,25,250
27,112,48,25,250
IBM
7

... (view more code including auto-cutter or 2nd drawer at http://keyhut.com/popopen.htm)