andrey-ushakov / esc_pos_utils

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

Align center not work print Image #79

Open arthas1888 opened 1 year ago

arthas1888 commented 1 year ago

I'm using the example code but it does not work, How can I center it?

      final ByteData data = await rootBundle.load('assets/image.png');
      final Uint8List imageBytes = data.buffer.asUint8List();

       final decodedImage = img.decodeImage(imageBytes)!;
       // Using `ESC *`
       bytes += generator.printImage(decodedImage, align: PosAlign.center);
GithubPranshul commented 1 year ago

hey, did you find any solution, and is your code printing the image I can't even print the image I can only print text. thanks

arthas1888 commented 1 year ago

I had to rewrite this lib

arthas1888 commented 1 year ago

the easy way is to create a new image and attach this image in it and center

GithubPranshul commented 1 year ago

thank you very much, if I'm understanding correctly then you were able to print the image at least right? because I can't and can't align the text either

arthas1888 commented 1 year ago

ok, for the text I had to rewrite the lib, and for images I had to create a new image with this package package:image/image.dart the width must be 380px, then attach the original image to this new image and center ir, that's all

GithubPranshul commented 1 year ago

Thank you

GithubPranshul commented 1 year ago

thanks once again, I was doing mistake in the width size ( printed two days ago though)

width must be 380px for me it's worked with 222