-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arabic Text not printing correctly #633
Comments
Hi @BaselAbdallah and welcome to python-escpos! You can add the from escpos import printer
x = printer.Network("192.168.192.168", profile=’TM-T20II’)
# x.charcode(code="CP864")
x.charcode(code="CP720") # Correct
text = "عصير"
x.textln(text)
x.cut() Does this work for your printer? EDIT on 11-May: The correct charcode seems to be "CP720" |
Hi @BaselAbdallah ! I had some time to take a second look at your issue. It looks like "CP720" is the correct charcode and it is also supported by your printer. You only have to pass the In response to the alignment of the text, python-escpos defaults to left aligned text. Did you try to set the printer to right align the characters? from escpos import printer
x = printer.Network("192.168.192.168", profile=’TM-T20II’)
x.charcode(code="CP720") # Surely you can omit this command
x.set(align="right")
text = "عصير"
x.textln(text)
x.cut()
x.close() Please, let us know if this works as many users would find this information useful. |
I have:
Bug description
•• Arabic Text not printing correctly:
• when testing this code:
from escpos import printer
x = printer.Network("192.168.192.168")
text = "عصير"
x.text(text)
x.cut()
It printed the text reversed "from left to right like that" and each character separated from the other. It printed like this: "ر ي ص ع"
• Then I tested using the code page "CP864" like this:
from escpos import printer
x = printer.Network("192.168.192.168")
x.charcode(code="CP864")
text = "عصير"
x.text(text)
x.cut()
It printed question marks instead of the Arabic characters. I tried using "CP720" and the result was similar to the first case, printed reversed and separated.
• Then I tried using _raw() to print instead of text() like this:
from escpos import printer
x = printer.Network("192.168.192.168")
x.charcode(code="CP864")
text = عصير"
def print_arabic_text(text):
reversed_text = text[::-1]
return reversed_text
x._raw(f"{print_arabic_text(text)}".encode("Arabic"))
x.cut()
exit()
The result was close to correct Arabic text, but not good enough.
•• How to print correct Arabic text?
Steps to reproduce
Device info
Printer: Epson TM-T20III
python version: 3.12.2
operating system: Windows 11
The text was updated successfully, but these errors were encountered: