Print Thai language
Asked Answered
B

3

4

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

I don't have any idea. Please help me. Would be a life savior.

Bearberry answered 31/12, 2018 at 8:9 Comment(0)
S
1

enter image description here

Here is the picture as I have described above in my comments. I have written a simple For..Next loop to print out the characters in the Thai codepage. From my picture I have highlighted the double char in the codepage and the char number of the Thai char.

Also, the third the printout shows the my code printing out Thai sentences with three lines for each Thai sentence. The first and third sentence has three lines.

Sanchez answered 8/1, 2019 at 19:23 Comment(5)
OK. I totally got it. Thanks for your help!! and I admire your knowledge. 감사합니다Bearberry
Hi, you did not know the extend I have had to go through in order to understand how to print Thai with ESC/POS. I asked two printer manufacturers, they don't have sample code to Thai. I asked Thai programmers on Facebook, they only told me about the three pass for Thai language. I asked my Thai girlfriend, she did not know. It took me three weeks, on and off research to be able to print Thai using ESC/POS. However, I am still not where near on how to print Vietnamese using ESC/POS. I can print Chinese/Japanese/Korean, but not Vietnamese. Do you know how to print it?Sanchez
Sorry, I have never tried Vietnamese. I have been working for KFC in Korea. I hope your problem is resolved soon.Bearberry
@Chi, I've done a POS that must support Chinese, Thai and Vietnamese for menu items and been banging my head supporting them all using Command mode plus hardware supported Encoding. Nothing works well enough, my final solution is to printing everything to Bitmap - and print the rasterized data.Laylalayman
I'm a little confused by this answer, as that list doesn't seem to have all the combinations needed. For example, how do I print นั as it consists of น and ัElective
S
4

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.

Sanchez answered 5/1, 2019 at 15:27 Comment(4)
I don't know this line means. For another example ดั้, has double top characters, you need to look up the character in the code page.Bearberry
The character ดั้ has three characters as shown in your printout! Two top characters and 1 middle character ด. In order to print the two top characters as one char, you need to look up the same double char in your printer's code for Thai language. My thermal printer code page for thai is 255, but your is 27.Sanchez
I have written a simple "For Next" code to print out the entire Thai codepage for my printer and once you have done the same, you will able to see how to lookup the double chars as one char. I can't add a picture else you will see how I have done it!Sanchez
How exactly do I print top, middle and bottom lines separately using ESC/POSElective
L
3

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.

Laylalayman answered 5/1, 2019 at 15:37 Comment(6)
Does printing a whole Bitmap slow print speeds?Bearberry
More or less the same! I did not get any complaints about printing speed from users thus spending no time for analyzing.Laylalayman
Yes, my first solution was, too, to use graphics solution which can print all language windows can support to the kitchen. But the invoice must be in English, windows font didn't looked good on English invoice, but using ESC/POS made the English invoice looked much better.Sanchez
What was the bad point of English invoice? We had the problem with mono-font, the Command mode is using mono font thus making it very easy to layout the content. I tried to apply the mono font on the bitmap as well and the problem solved. An example image can be found hereLaylalayman
I like your invoice printout. Very nicely layout. The standard Epson ESC/POS font is FontA11 which looks normal and the same as other invoice/receipt from other software.Sanchez
Put up the printing into a library using Swift (will get the C# on nuget later) which can be found here. Hope it could be useful to others.Laylalayman
S
1

enter image description here

Here is the picture as I have described above in my comments. I have written a simple For..Next loop to print out the characters in the Thai codepage. From my picture I have highlighted the double char in the codepage and the char number of the Thai char.

Also, the third the printout shows the my code printing out Thai sentences with three lines for each Thai sentence. The first and third sentence has three lines.

Sanchez answered 8/1, 2019 at 19:23 Comment(5)
OK. I totally got it. Thanks for your help!! and I admire your knowledge. 감사합니다Bearberry
Hi, you did not know the extend I have had to go through in order to understand how to print Thai with ESC/POS. I asked two printer manufacturers, they don't have sample code to Thai. I asked Thai programmers on Facebook, they only told me about the three pass for Thai language. I asked my Thai girlfriend, she did not know. It took me three weeks, on and off research to be able to print Thai using ESC/POS. However, I am still not where near on how to print Vietnamese using ESC/POS. I can print Chinese/Japanese/Korean, but not Vietnamese. Do you know how to print it?Sanchez
Sorry, I have never tried Vietnamese. I have been working for KFC in Korea. I hope your problem is resolved soon.Bearberry
@Chi, I've done a POS that must support Chinese, Thai and Vietnamese for menu items and been banging my head supporting them all using Command mode plus hardware supported Encoding. Nothing works well enough, my final solution is to printing everything to Bitmap - and print the rasterized data.Laylalayman
I'm a little confused by this answer, as that list doesn't seem to have all the combinations needed. For example, how do I print นั as it consists of น and ัElective

© 2022 - 2024 — McMap. All rights reserved.