I'm following this post (Printing directly to a thermal printer using ESC/POS Commands executed in C# with an interface of TCP/IP) and I'm able to send text strings to the Ethernet thermal printer and it prints correctly. But I want to print unicode characters and I'm not able to.
I have a unicode character text string, PC is able to show that correctly at MessageBox.Show() etc.. and I want the thermal printer to print the same.
I have tried all the encoding methods but Ethernet thermal printer will print funny characters. If using ASCII, it will print '?'
byte[] data1 = System.Text.Encoding.Default.GetBytes(textString);
byte[] data2 = System.Text.Encoding.UTF32.GetBytes(textString);
byte[] data3 = System.Text.Encoding.UTF8.GetBytes(textString);
byte[] data4 = System.Text.Encoding.UTF7.GetBytes(textString);
byte[] data5 = System.Text.Encoding.Unicode.GetBytes(textString);
I also print the unicode characters on to a graphics area, and my regular USB inkjet printer prints that correctly. I try converting the graphics to byte array and send to the Ethernet thermal printer, that is not working either.
MemoryStream stream = new MemoryStream();
Bitmap bitmap = new Bitmap(width, height, graphics);
bitmap.Save(stream, ImageFormat.Bmp);
byte[] byteArray = stream.GetBuffer();
clientSock.Send(byteArray);
It is a big byteArray data, but the Ethernet thermal printer will print a few funny characters and that's it.
I'm working on a existing HW platform which the current SW can print unicode characters to the same Ethernet thermal printer. I'm trying to develop the SW to replace the existing one. I don't know how the existing SW is doing it, but I guess it will just send data into TCP/IP socket and shouldn't be any driver dependency...
Anyone knows how to achieve this? Thanks in advance.