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));
}
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));
}