andrey-ushakov / esc_pos_utils

Basic Flutter/Dart classes for ESC/POS printing
BSD 3-Clause "New" or "Revised" License
140 stars 306 forks source link

Arabic Text Issue #31

Open ahmedahel opened 3 years ago

ahmedahel commented 3 years ago

Hi Dear,

I'm trying to print receipt in Arabic language but the text some times appear as Inverse and dashed My Printer Model is : TM-m30 . Table Code WPC1256 , PC864 and PC720 . CharsetConverter: cp864, windows-1256.

I get these code from https://reference.epson-biz.com/modules/ref_charcode_en/index.php?content_id=47.

jacobokoenig commented 3 years ago

@ahmedahel how are you encoding the text? Can you share some code?

ahmedahel commented 3 years ago

Uint8List encoded = await CharsetConverter.encode('windows-1256', "فاتورة ضريبة"); printer.textEncoded(encoded, styles: PosStyles(codeTable: 'PC850', bold: true, align: PosAlign.center));

s2yed commented 3 years ago

I have the same problem with printing

ahmedahel commented 3 years ago

@andrey-ushakov Is there any updates ?

s2yed commented 3 years ago

Is there any updates ?

xSuperMu commented 3 years ago

I'm facing the same issue!

xSuperMu commented 3 years ago

which version of the esc_pos_utils do you use?

xSuperMu commented 3 years ago

Uint8List encoded = await CharsetConverter.encode('windows-1256', "فاتورة ضريبة"); printer.textEncoded(encoded, styles: PosStyles(codeTable: 'PC850', bold: true, align: PosAlign.center));

I've tested this code and it printed different characters! would you please provide a complete example?

ahmedahel commented 3 years ago

const PaperSize paper = PaperSize.mm80; final profile = await CapabilityProfile.load(); final printer = NetworkPrinter(paper, profile); final PosPrintResult res = await printer.connect(printerIp, port: 9100);

if(res == PosPrintResult.success ){ Uint8List encoded = await CharsetConverter.encode('windows-1256', "فاتورة ضريبة"); printer.textEncoded(encoded,styles:PosStyles(codeTable: 'PC850', bold: true, align: PosAlign.center)); printer.feed(1); printer.cut();

}

ahmedahel commented 3 years ago

@jacobokoenig please update us as soon as possible

nicks258 commented 2 years ago

Any updates? Facing same issue.

bluemix commented 2 years ago

I hope there are updates to this issue

alasriaj commented 2 years ago

Yes, I faced the same problem I hope there are updates to this issue

bluemix commented 2 years ago

see this solution:

https://github.com/kakzaki/blue_thermal_printer/issues/82#issuecomment-1048964685

iyashiyas commented 2 years ago

@jacobokoenig please update us as soon as possible

any solution ? still i have issue

bluemix commented 2 years ago

@iyashiyas go to the printer settings, and then set the printing encoding to UTF-8

iyashiyas commented 2 years ago

@bluemix still not working, const characterSet = 'CP1256';

    Uint8List encSeller =
        await CharsetConverter.encode(characterSet, "عمل الطباعة العربية");

    bytes += ticket.textEncoded(encSeller,
        styles: const PosStyles(
          height: PosTextSize.size2,
          width: PosTextSize.size2,
          align: PosAlign.center,
          bold: true,
        ));

my printer is epson tm m-30

iyashiyas commented 2 years ago

see this solution:

kakzaki/blue_thermal_printer#82 (comment)

i have done same this but issue is image printing slowly. it is only a temporary solution the large data will not print.

bluemix commented 2 years ago

in printer settings, i mean, the Android settings of the device. @iyashiyas

iyashiyas commented 2 years ago

@bluemix no use.. there is no option to change

AbdurrahmanElrayes commented 2 years ago

You have to find the character table for your printer and write the corresponding commands to let the printer know that you are printing multi byte characters such as Arabic characters. In my case, I was using sunmi printer and the only thing that worked for me was finding its character table and I wrote the commands and it worked very well. Here's a picture of what they said in the documentation.

image

And this is what I did and it printed arabic perfectly


final encodedStr = utf8Encoder.convert(invoice.description);
bytes += generator.textEncoded(Uint8List.fromList([
  ...[0x1C, 0x26, 0x1C, 0x43, 0xFF],
  ...encodedStr
]))
mfrouh commented 2 years ago

Thank you @AbdurrahmanElrayes for the effort!

SohybBinselm commented 2 years ago

Thank you so much, this is the only solution that worked for me. @AbdurrahmanElrayes

sgsm74 commented 1 year ago

You have to find the character table for your printer and write the corresponding commands to let the printer know that you are printing multi byte characters such as Arabic characters. In my case, I was using sunmi printer and the only thing that worked for me was finding its character table and I wrote the commands and it worked very well. Here's a picture of what they said in the documentation.

image

And this is what I did and it printed arabic perfectly

final encodedStr = utf8Encoder.convert(invoice.description);
bytes += generator.textEncoded(Uint8List.fromList([
  ...[0x1C, 0x26, 0x1C, 0x43, 0xFF],
  ...encodedStr
]))

not working for me. it still printing Chinese characters

AbdurrahmanElrayes commented 1 year ago

You have to find the character table for your printer and write the corresponding commands to let the printer know that you are printing multi byte characters such as Arabic characters. In my case, I was using sunmi printer and the only thing that worked for me was finding its character table and I wrote the commands and it worked very well. Here's a picture of what they said in the documentation. image And this is what I did and it printed arabic perfectly

final encodedStr = utf8Encoder.convert(invoice.description);
bytes += generator.textEncoded(Uint8List.fromList([
  ...[0x1C, 0x26, 0x1C, 0x43, 0xFF],
  ...encodedStr
]))

not working for me. it still printing Chinese characters

What printer do you use?

sgsm74 commented 1 year ago

You have to find the character table for your printer and write the corresponding commands to let the printer know that you are printing multi byte characters such as Arabic characters. In my case, I was using sunmi printer and the only thing that worked for me was finding its character table and I wrote the commands and it worked very well. Here's a picture of what they said in the documentation. image And this is what I did and it printed arabic perfectly

final encodedStr = utf8Encoder.convert(invoice.description);
bytes += generator.textEncoded(Uint8List.fromList([
  ...[0x1C, 0x26, 0x1C, 0x43, 0xFF],
  ...encodedStr
]))

not working for me. it still printing Chinese characters

What printer do you use?

SRP-330ii and an inbuilt printer(Citaq H10 POS)

AbdurrahmanElrayes commented 1 year ago
image

You can try this command and set the code page to 22 or 40 for arabic characters. That's what the printer manuals says. you can find it in this pdf page 47: https://data2.manualslib.com/pdf7/272/27101/2710088-bixolon/srp330ii.pdf?744f2c5cdecdd9e0c41f9ce36783ab22

@sgsm74

sgsm74 commented 1 year ago
image

You can try this command and set the code page to 22 or 40 for arabic characters. That's what the printer manuals says. you can find it in this pdf page 47: https://data2.manualslib.com/pdf7/272/27101/2710088-bixolon/srp330ii.pdf?744f2c5cdecdd9e0c41f9ce36783ab22 @sgsm74

Thank you so much, what about the other device??do you got anything??I can print on it but It is reversed like:م ا ل س

AbdurrahmanElrayes commented 1 year ago
image

You can try this command and set the code page to 22 or 40 for arabic characters. That's what the printer manuals says. you can find it in this pdf page 47: https://data2.manualslib.com/pdf7/272/27101/2710088-bixolon/srp330ii.pdf?744f2c5cdecdd9e0c41f9ce36783ab22 @sgsm74

Thank you so much, what about the other device??do you got anything??I can print on it but It is reversed like:م ا ل س

You're welcome. Unfortunately, I couldn't find detailed docs about this printer yet.

hadyk77 commented 1 year ago

You have to find the character table for your printer and write the corresponding commands to let the printer know that you are printing multi byte characters such as Arabic characters. In my case, I was using sunmi printer and the only thing that worked for me was finding its character table and I wrote the commands and it worked very well. Here's a picture of what they said in the documentation. image And this is what I did and it printed arabic perfectly

final encodedStr = utf8Encoder.convert(invoice.description);
bytes += generator.textEncoded(Uint8List.fromList([
  ...[0x1C, 0x26, 0x1C, 0x43, 0xFF],
  ...encodedStr
]))

not working for me. it still printing Chinese characters

What printer do you use?

Can you help me with epson tm30 please ?

imwa5i7 commented 1 year ago

I tried the above solutions but they didn't work out for me. my Arabic code page is 92. Do I need to change anything in these numbers? [0x1C, 0x26, 0xM1C, 0x43, 0xFF]

Ashbuhrz commented 1 year ago

I am using bixolon srp-e300 and it's code table is 22. (https://bixolon.com/_upload/manual/Manual_SRP-E300302_Code_Page_english_Ver_1_01.pdf).

but i am still getting some random arabic letters

s2yed commented 1 year ago

I tried the above solutions but they didn't work out for me. my Arabic code page is 92. Do I need to change anything in these numbers?

waqadArshad commented 11 months ago

Hi, it's very easy to support utf8 encoding which would help you print many languages. You just have to add an entry in the default section of capabilities.json and if you don't want to bother with that, you can use my fork:

https://github.com/waqadArshad/esc_pos_utils

as:

  esc_pos_utils:
    git:
      url: https://github.com/waqadArshad/esc_pos_utils.git

and if it fixes your issue, please remember to STAR the repo.

EmreSURK commented 11 months ago

Hi, it's very easy to support utf8 encoding which would help you print many languages. You just have to add an entry in the default section of capabilities.json and if you don't want to bother with that, you can use my fork:

https://github.com/waqadArshad/esc_pos_utils

as:

  esc_pos_utils:
    git:
      url: https://github.com/waqadArshad/esc_pos_utils.git

and if it fixes your issue, please remember to STAR the repo.

Hi, is it possible to explain more? For example, should we give a specific profile, or how to select the UTF8 you added?