0

Been trying to print to my EPSON TM-T88IIIP printer using C# and RawPrinterHelper class, so far i could only print text, now what i need is to print graphics but the EPSON documentation for this is not clear.

This is my code for printing text:

    static string printerName = "Epson TM-T88III";
    static string ESC = Convert.ToString((char)27);
    static string LF = Convert.ToString((char)10);
    static string GS = Convert.ToString((char)29);
    static string cutCommand = $"{ESC}@{GS}V{(char)66}{(char)0}";

    static void Main(string[] args)
    {
        PrintText();
        //PrintGraphics();
    }

    private static void PrintText()
    {                        
        byte[] bytes = Encoding.Unicode.GetBytes($@"{ESC}COMPANYNAME.{LF}COMPANY ADDRESS{LF}RANDOM TEXT{LF}__________________________________________{LF}{(char)179}1234567890123456789012345678901234567890{(char)179}{LF}{(char)196}{LF}");
        RawPrinterHelper.SendBytesToPrinter(printerName, bytes);
        RawPrinterHelper.SendBytesToPrinter(printerName, Encoding.ASCII.GetBytes(cutCommand));
    }

RawPrinterHelper code

And it works perfectly fine, now graphics command goes something like this:

Command Definition = '// GS ( L pL pH m fn a kc1/Kc2 b xL xH yL yH c

Command Execution = GS "(L" 139 7 48 67 48 "G1" 1 128 0 120 0 49

Here is the problem, how to escape all those parameters in ASCII, my code so far:.

public static void PrintGraphics()
    {                        
        byte[] commandBytes = Encoding.ASCII.GetBytes($"{ESC}@{GS}{(char)40}{(char)76}{(char)139}{(char)7}{(char)48}{(char)67}{(char)48}G1{(char)1}{(char)128}{(char)0}{(char)120}{(char)0}{(char)49}");
        //byte[] commandBytes = Encoding.Unicode.GetBytes($"{ESC} (L 139 7 48 67 48 G1 1 128 0 120 0 49");
        byte[] imageBytes = Example.GetExampleImageBytes();
        byte[] commandEndBytes = Encoding.ASCII.GetBytes($"{ESC}@{GS}{(char)40}{(char)76}{(char)6}{(char)0}{(char)48}{(char)69}G1{(char)1}{(char)1}");
        byte[] endBytes = commandBytes.Concat(imageBytes).Concat(commandEndBytes).ToArray();
        RawPrinterHelper.SendBytesToPrinter(printerName, endBytes);
        RawPrinterHelper.SendBytesToPrinter(printerName, Encoding.ASCII.GetBytes(cutCommand));
    }

EPSON Commands List

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • To print graphics, you need to know what its documentation means by "bit image", and how the data is formatted. The command-list does not have that information. – Thomas Dickey Oct 29 '15 at 22:27
  • I found how data should be formatted in this post http://stackoverflow.com/questions/14099239/printing-a-bit-map-image-to-pos-printer-via-comport-in-c-sharp and then just send the bytes to the printer using the RawPrinter methods – Andrés Monsalve Nov 03 '15 at 14:46

0 Answers0