0

I am working on C# POS. I am using raw printing helper and I am trying to print an image using ESC/POS commands with the command: ESC *.

So far I am able to:

string carriageReturn = Convert.ToString((char)13);
string lineFeed = carriageReturn + Convert.ToString((char)10);
string cutPaper = Convert.ToString((char)27) + Convert.ToString((char)105);
string horizontalTab = Convert.ToString((char)9);
string fontSize4 = Convert.ToString((char)29) + Convert.ToString((char)33) + Convert.ToString((char)51);

And I send the data to print with this:

printWithStringAndPrinter(fontSize4 + "this" + lineFeed + "is" + lineFeed + fontSize2 + "test" + lineFeed + cutPaper, p.name);

The only problem is with the image, I can not get it to print. I have tried this:

Bitmap bmp = new Bitmap("C:\\test.bmp");
string image = Convert.ToString((char)27) + Convert.ToString((char)42) + Convert.ToString((char)33) + Convert.ToString((char)0) + Convert.ToString((char)86) + bmp.ToString();

But nothing works. Can someone give an advice or an example of how to print an image?

Even though there are a lot of questions about the same topic, any of them has helped me.

Fernando Santiago
  • 2,128
  • 10
  • 44
  • 75
  • Basically, string is Unicode (16bit) data, so it is different from ESC/POS command & data. You have to create a byte array as data to send to the printer. For example, refer to these articles. [Printing a Bit map image to pos printer via comport in C#](https://stackoverflow.com/q/14099239/9014308), [how to print images with ESC/POS commands?](https://stackoverflow.com/q/36952668/9014308), [Convert raster byte\[\] image data to column Format in C#](https://stackoverflow.com/q/60136821/9014308) – kunif Feb 20 '20 at 08:58

0 Answers0