Logo not printing properly with thermal printer flutter

Viewed 191

I am trying to print a network image that is in the database using the thermal printer on my receipt. I am using esc_pos_bluetooth package from pub.dev.

I am resizing the image because it may be of any size. so making it suitable for print

In the below function I am getting the image from the network and then converting it into bytes for printing. and simply returning it by resizing.

Future<Image.Image> resizeImg(String path) async {
    String imageUrl = 'http://example.co.in/images/$path.png';
    http.Response response = await http.get(imageUrl);
    Uint8List bytes = response.bodyBytes;
    final Image.Image imgs = Image.decodeImage(bytes);
    final Image.Image ig = Image.copyResize(imgs, height: 150, width: 120);
    return ig;
  }

and for the print purpose, I am calling ticket.image method.

final Image.Image img = await resizeImg(data['logo']);
 ticket.image(img);

The problem is when the image is printed it's not getting printed correctly. The border of the image is scattered. You can see it here mis printed image

What is the correct way to print an image?. So it will be printed perfectly.

Note: If somebody could explain what can be the possible reasons of not printing correctly it will be really helpful. Sometimes after adjusting image dimensions it worked. but this is not a perfect solution

0 Answers
Related