kakzaki / blue_thermal_printer

Working with thermal printer via bluetooth (Flutter)
MIT License
166 stars 211 forks source link

is there charset code that support Arabic text #82

Closed ebrahimmansur closed 2 years ago

ebrahimmansur commented 3 years ago

need to print invoice in Arabic...thank you

kreemov commented 3 years ago

windows-1256 worked with me

ebrahimmansur commented 3 years ago

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

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

fatimaown93 commented 3 years ago

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 commented 3 years ago

windows-1256 worked with me

how did you did it ?!

ebrahimmansur commented 3 years ago

still nothing....

fatimaown93 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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

ebrahimmansur commented 2 years ago

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

this is the output

IMG_20211203_212732 .

Salakar commented 2 years ago

Can I ask the make/model of the printer?

ebrahimmansur commented 2 years ago

that is the problem we don’t have constraint on what printer the merchant uses, we only provide the connection and printing functionality....if we did we could have used the printer's sdk...😁

On Fri, Dec 3, 2021 at 9:37 PM Mike Diarmid @.***> wrote:

Can I ask the make/model of the printer?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kakzaki/blue_thermal_printer/issues/82#issuecomment-985778251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIIKSN6BKN3RMY5SLVIYBLLUPEL75ANCNFSM45PBJ7DA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Salakar commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

devmuaz commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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