0

I'm able to print out my images on receipt paper, but the problem I faced is that the image is line by line which is a problem.

Below is my code

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

    bytes += generator.image(image);

Here is the result of printing it out. enter image description here

  • If you're using a system-level printing service are you able to print graphics to that printer with other applications? – Pat9RB Oct 07 '21 at 01:58
  • Your question seems to lack the information that others need to investigate, reproduce, or fix the problem. For example, the printer vendor, model number, library used, and minimum source code. [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask), [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) By the way, do you adjust the amount of line spacing? [ESC 3](https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=20), [Recent similar article](https://stackoverflow.com/q/69448545/9014308) – kunif Oct 07 '21 at 03:49

2 Answers2

0

Use this function:

  initSavetoPath() async {
    //read and write
    //image max 300px X 300px
    final filename = 'logo_a.png';
    var bytes = await rootBundle.load("assets/images/logo_a.png");
    String dir = (await getApplicationDocumentsDirectory()).path;
    writeToFile(bytes, '$dir/$filename');
    setState(() {
      pathImage = '$dir/$filename';
    });
  }

Check out this package: Click here!

Bilal Saeed
  • 2,092
  • 8
  • 31
0

You Can use imageRaster instead than image

bytes += generator.imageRaster(image);

and it will work