Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

is there charset code that support Arabic text #82

Closed
ebrahimmansur opened this issue May 25, 2021 · 20 comments
Closed

is there charset code that support Arabic text #82

ebrahimmansur opened this issue May 25, 2021 · 20 comments

Comments

@ebrahimmansur
Copy link

need to print invoice in Arabic...thank you

@kreemov
Copy link

kreemov commented Jun 9, 2021

windows-1256 worked with me

@ebrahimmansur
Copy link
Author

ebrahimmansur commented Jun 20, 2021

please provide gist of the code ....here is mine

String voucherNameWithValueMessage = 'ليبيانا 5 دينار'; blueThermalPrinter.printCustom( voucherNameWithValueMessage, _onlyBoldText, _alignCenterText, charset: 'windows-1256');

@fatimaown93
Copy link

please provide gist of the code ....here is mine

String voucherNameWithValueMessage = 'ليبيانا 5 دينار'; blueThermalPrinter.printCustom( voucherNameWithValueMessage, _onlyBoldText, _alignCenterText, charset: 'windows-1256');

me too it's not working for me
did you solve it ? if so
I really need help

@fatimaown93
Copy link

windows-1256 worked with me

how did you did it ?!

@ebrahimmansur
Copy link
Author

still nothing....

@fatimaown93
Copy link

still nothing....

actually I find a way but it's really twisted 🤣
WhatsApp Image 2021-07-30 at 2 45 26 PM
I used canvas textpainter and then convert it to an image
then I used the function printImageBytes
It works but there was a problem the function printimage has a fixed height for the image [200px - 250px]. I will try to make it more than one image on sunday.

@ebrahimmansur
Copy link
Author

please provide gist of the code ....here is mine
String voucherNameWithValueMessage = 'ليبيانا 5 دينار'; blueThermalPrinter.printCustom( voucherNameWithValueMessage, _onlyBoldText, _alignCenterText, charset: 'windows-1256');

me too it's not working for me
did you solve it ? if so
I really need help

still nothing....

actually I find a way but it's really twisted 🤣
WhatsApp Image 2021-07-30 at 2 45 26 PM
I used canvas textpainter and then convert it to an image
then I used the function printImageBytes
It works but there was a problem the function printimage has a fixed height for the image [200px - 250px]. I will try to make it more than one image on sunday.

not an efficient solution ....i thought about make it an pdf then printing it as an image before.....still not really a solution 😂...so still waiting on @kreemov to show me if it really works.

@Salakar
Copy link

Salakar commented Dec 3, 2021

What's the result of using utf-8 as the charset?

@ebrahimmansur
Copy link
Author

What's the result of using utf-8 as the charset?

this is the output

IMG_20211203_212732
.

@Salakar
Copy link

Salakar commented Dec 3, 2021

Can I ask the make/model of the printer?

@ebrahimmansur
Copy link
Author

ebrahimmansur commented Dec 3, 2021 via email

@Salakar
Copy link

Salakar commented Dec 3, 2021

I see 😅 the only other thing I can suggest is try print through a quick Node.js script with something like https://www.npmjs.com/package/node-thermal-printer that's known to support Arabic - if it works with that then it confirms it's an issue with this plugin and not the printer

@ebrahimmansur
Copy link
Author

Thanks ...and also thanks a lot for the support ✌️ ... i appreciate the time .......can’t with for the next space ...it’s seems my issue with the "multi package" was not fully understood because of its complexity and with out having visual representation 😅😭

@bluemix
Copy link

bluemix commented Feb 23, 2022

Go to the device POS settings, and on print settings, set printing with UTF-8.

If the above method doesn't work, try the next method (which is printing images as text).

Solution inspired from @fatimaown93.

You can convert the widget into an image (using Screenshot) and print it:

image

Here is the Widget:

Screenshot(
    controller: screenshotController,
    child: Container(
      width: 190,
      decoration: BoxDecoration(
          border: Border.all(color: Colors.black),
        color: Colors.white,
      ),
      // color: Colors.white,
      child: Column(
        children: [
          Row(
            children: [
              Text(
                'أهلاً وسهلاً',
                style: TextStyle(
                  color: Colors.black,
                ),
                textAlign: TextAlign.right,
              ),
              Spacer(),
              Text(
                'شكو ماكو؟',
                style: TextStyle(
                  color: Colors.black,
                ),
              ),
            ],
          ),
  
        ],
      ),
    ),
  ),

The widget is converted into image of Uint8List:

var imageTextRawUint8List = await screenshotController.capture() ?? Uint8List(0);

Then, print the image bytes:

 bluetooth.printImageBytes(imageTextRawUint8List);

@ebrahimmansur
Copy link
Author

ebrahimmansur commented Mar 5, 2022

Thanks so much @bluemix ,but I have already thought about it and implemented it if you have seen the conversion between me and @fatimaown93, but I want is an efficient solution , I wish if there was a way to convert codepage to utf-8 command as binary message to the thermal printer. Im still trying to test some things , I will keep you posted if I came with a better solution (I don't want to depend on a package not made for this problem and bound/scoped to a UI logic that can change over time ) .

@iyashiyas
Copy link

windows-1256

how? can u share the code please
or correct if i am wrong
Uint8List encoded =
await CharsetConverter.encode('windows-1256', message.toString());
printer.textEncoded(encoded);

@bluemix
Copy link

bluemix commented May 29, 2022

you have to go the printer settings menu (Android settings) and set the encoding to utf-8 or windows-1256

@devmuaz
Copy link

devmuaz commented Jun 14, 2022

Changing the printer settings (can be found in the android settings) worked for me, I set it to UTF-8 and now it's printing Arabic characters!
Thanks @bluemix 👏

@blitzlepe
Copy link

Can you share the path of file(to) to edit?

Changing the printer settings (can be found in the android settings) worked for me, I set it to UTF-8 and now it's printing Arabic characters! Thanks @bluemix 👏

Can you share the path of file(to) to edit?

@devmuaz
Copy link

devmuaz commented Aug 20, 2022

@blitzlepe It's in the system settings, there must be a section called Printer where you can change the encoding to UTF-8

Repository owner locked and limited conversation to collaborators Aug 26, 2022
@kakzaki kakzaki converted this issue into discussion #163 Aug 26, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants