0

PART 1

I am currently trying to get my printer to properly output Greek and not GreekLish for my restaurant ordering system.

I am using python-escpos.

- My code looks like this.

from escpos.printer import Usb
p = Usb(0x471, 0x55, 0, 0x82, 0x2)
p.charcode(code='Greek')
p.text('Καλημέρα \n')
p.cut()
p.close()

- My output looks like this.

failure 1

Is there an issue with my string input? Am I supposed to encode it?

Also, The library works currently in shops. The issue is instead of printing, for example, Καλημερα I have to print Kalimera, greeklish. I need it to look more professional.

Thank you

PART 2

Added the encoding magic still nothing...

from escpos.printer import Usb
from escpos.exceptions import USBNotFoundError
from escpos.magicencode import MagicEncode, Encoder
import requests


resp = requests.get('https://raw.githubusercontent.com/receipt-print-hq/escpos-printer-db/3612db407d02a08acd93a1540f2b4823be3f020e/dist/capabilities.json')
js = resp.json()
encodings = list(js['encodings'].keys())

for encoding in encodings:
    print(encoding)
    try:
        p = Usb(idVendor=0x471, idProduct= 0x55,in_ep=0x82, out_ep=0x02)
        p.magic.force_encoding(encoding)
        p.text(encoding)
        p.text('ΚΑΛΗΜΕΡΑ \n')
            p.cut()
        p.close()
        
    except USBNotFoundError:
        print('printer not connected or on')

    except Exception as e:
        print(e)

My output looks like this...

failure #2

No Greek Goodmorning for me... I believe I am very close. Any other suggestions?

PART 3

how about we enter some command in the second _raw function?

p = Usb(idVendor=0x471, idProduct= 0x55,in_ep=0x82, out_ep=0x02)

ESC = b'\x1b'

p._raw(ESC + b'\x74\x07') # page 28-29 printer manual

p._raw( add something...)  # need to print Καλημερα

p.cut()
p.close()

HELPFULL

  • printer model Alpha TP-80H

  • programmers manual

  • the printer also came with a self-test page.

page 1

page 2

George Pamfilis
  • 1,397
  • 2
  • 19
  • 37
  • A GitHub issue solved the problem by converting foreign text into an image. I would prefer to figure this out first. – George Pamfilis Mar 10 '22 at 10:09
  • Why not try using `cp1253` or `iso8859_7` instead of `Greek`? [Magic Encode](https://python-escpos.readthedocs.io/en/latest/api/magicencode.html), [escpos-printer-db/dist/capabilities.json](https://github.com/receipt-print-hq/escpos-printer-db/blob/3612db407d02a08acd93a1540f2b4823be3f020e/dist/capabilities.json) – kunif Mar 11 '22 at 00:33
  • I looped through the capabilities forcing the encodings, it is shown in part 2 of this post. still nothing @kunif. – George Pamfilis Mar 13 '22 at 11:38
  • For example, why not output it to a file if possible and check if the data content is correct? If that doesn't work, why not put an Issue in the repository? [python-escpos/python-escpos/issues](https://github.com/python-escpos/python-escpos/issues) – kunif Mar 13 '22 at 14:28
  • Version 2.2.0 installed with `pip install python-escpos` seems to be buggy and unusable. It also doesn't match the documentation. Perhaps it was created for a customized printer from some vendor rather than the standard ESC/POS. Please install and use the latest version under development from the github repository. It seems that you can do it with `p.charcode(code='CP1253')` without using `MagicEncode`. Perhaps the `iconv` command needs to be properly installed and enabled. – kunif Mar 15 '22 at 08:33
  • Or, perhaps your printer has different specifications than the standard ESC/POS. – kunif Mar 15 '22 at 08:49
  • I am using the python-escpos==3.0a6 and my printer is Alpha tp 80h. And it also provides me with a codepage. Ill add it to my question. – George Pamfilis Mar 15 '22 at 15:01
  • In the environment of Windows10 Python 3.10.2, based on the first code of the question, when the output destination is `printer.File` and the code is `CP1253`, the following result is obtained in hexadecimal string representation. `1B,74,2F,CA,E1,EB,E7,EC,DD,F1,E1,20,0A,1B,64,06,1D,56,00` These bytes seem appropriate. – kunif Mar 15 '22 at 15:22
  • Looking at the results of the self-test page, the code page layout does not meet the EPSON specifications. [ESC t](https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=32) If it's just about encoding issues, it's probably better to lower the version of python-escpos to 2.2.0 and try it with the first code `Greek` in the question. Alternatively, you may be able to add and specify your printer information to a database that describes the attributes of each company's printer. [escpos-printer-db](https://github.com/receipt-print-hq/escpos-printer-db) – kunif Mar 15 '22 at 15:54
  • It does meet them (EPSON) I just added a missing section of the page, sorry. I also added a programmer's manual for the printer. maybe I can send a custom command with the _raw method. What will that look like? – George Pamfilis Mar 15 '22 at 16:16
  • It is more versatile and will help others to register and use data that shows the characteristics and attributes of the printer in the database, rather than sending a special custom command. For example, why not create and register this kind of data for your printer? [escpos-printer-db/data/profile/POS-5890.yml](https://github.com/receipt-print-hq/escpos-printer-db/blob/master/data/profile/POS-5890.yml) – kunif Mar 15 '22 at 16:26
  • I will definitely create a profile for them. But, I need a quick solution by using the _raw or something else. Trust me, I will devote a whole blog post to my nightmare and how it was resolved. – George Pamfilis Mar 15 '22 at 16:30
  • I'm not actually using python-escpos so I don't know what to do with such customization. If you want to try it quickly, why not try the 2.2.0 version mentioned in the previous comment? – kunif Mar 15 '22 at 16:36
  • ill give it a try with your suggested version. what do you use ? and what would your example look like in code? – George Pamfilis Mar 15 '22 at 16:42
  • 2.2.0 came in when I installed it on Windows 10 without specifying the version. Looking at the source code, the `Greek` code page had a value of `7`, so I thought it matched the attributes of your printer. – kunif Mar 15 '22 at 16:51

1 Answers1

0

Use the charcode and the codepage

The following code works with my NT-5890K printer

p = printer.Usb(0x0416,0x5011, in_ep=0x81, out_ep=0x03)
p.charcode(code='Greek')
p.codepage = 'CP1253''
p.text('Καλημέρα \n')
p.cut()
p.close()
I. Kostas
  • 1
  • 1