Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent incorrect separated characters when printing receipts using ESC/POS in C#?

Tags:

c#

escpos

I have an application which print the receipt to receipt printer using ESC/POS. It needs to support Thai language.

When I tried to print Thai language, some of the characters are being separated like this photo:

photo

Here is my code:

printMSG = Command.ESC + "t" + Command.DecimalToCharString(27);
port.Write(printMSG);
var enc = Encoding.GetEncoding("windows-874");
string content = "ข้าวผัดอินโดนีเซียกับเครื่องเทศแบบดั้ง";
byte[] bytes = enc.GetBytes(content);
port.Write(bytes, 0, bytes.Length); 
like image 576
Hannim Lee Avatar asked Sep 05 '25 03:09

Hannim Lee


2 Answers

Thai language is called a three-pass language. Which means print the top line, middle line and bottom line separately.

For example รื่ has top and middle characters, you must print them on each lines, from your picture these are printed at bottom, hence as top line.

For another example ดั้, has double top characters, you need to look up the character in the code page.

There are others bottom characters, these will be printed at top hence as bottom line.

Do some testing, you will get it.

like image 143
Chi Avatar answered Sep 07 '25 20:09

Chi


Printing with Command mode would required the support from hardware (in my case Star Micronics). I ran into the same problem and could only solve it by rasterizing the whole content into Bitmap then print the whole Bitmap.

like image 30
Chinh Nguyen Avatar answered Sep 07 '25 21:09

Chinh Nguyen