question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Print image for first time it work. but next time layout change position [Thermal Printer Model GG-5805DD]

See original GitHub issue
  Future _printThermalBluetooth() async {
    print('_printThermalBluetooth');
    this
        ._screenshotCustomer
        .capture(delay: Duration(milliseconds: 10), pixelRatio: 3)
        .then((Uint8List captureImage) async {
      print('_printThermalBluetooth ====> $captureImage');
      bluetooth.isConnected.then((isConnected) async {
        if (isConnected) {
          var image = decodeImage(captureImage);
          image = copyResize(image, width: 380);
          Uint8List imageByte = encodePng(image);
          print('_printThermalBluetooth ====> $imageByte');
          print('_printThermalBluetooth asUint8List ====> ${imageByte.offsetInBytes}   ${imageByte.lengthInBytes}');
          bluetooth.printImageBytes(imageByte.buffer
              .asUint8List(imageByte.offsetInBytes, imageByte.lengthInBytes));
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.printNewLine();
          bluetooth.paperCut();
          _disconnect();
        }
      });
    });
  }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

5reactions
V00doo1commented, Aug 8, 2021

I found a work around. So with my printer it seems the consecutive print misaligns if the height of the image is more than 200 px.

  1. So I installed an image manipulation library.
  2. Cropped the image into separate 200 px with the Crop copy function.
  3. printed each one separately. but the final print still looks like it’s one image.

Image manipulation library I used: https://pub.dev/packages/image

4reactions
V00doo1commented, Aug 5, 2021

I found a work around. So with my printer it seems the consecutive print misaligns if the height of the image is more than 200 px.

  1. So I installed an image manipulation library.
  2. Cropped the image into separate 200 px with the Crop copy function 3.printed each one separately. but the final print still looks like it’s one image.

Image manipulation library I used: https://pub.dev/packages/image

I try this, it gave me blank space between the images, can you share this part of your code with us to see your way of doing it ?

this is my code

` var picture = recorder.endRecording(); var img = await picture.toImage(470, position.ceil()); var pngBytes = await img.toByteData(format: ImageByteFormat.png); im.Image receiptImg = im.decodeImage(pngBytes.buffer.asUint8List());

var img_count = position / 200;

List<List<int>> imgList = [];
for (var i = 0; i < img_count.round(); i++) {
  var cropedReceiptImg = im.copyCrop(receiptImg, 0, (i * 200), 470, 200);
  var bytes = im.encodePng(cropedReceiptImg);
  imgList.add(bytes);
}
imgList.forEach((element) {
  bluetooth.printImageBytes(element);
});`

here’s my code. it has been changed to match with your variable names. i’m not sure what your img_count variable is but the for loop must go on for the full height of the image.

List<List<int>> imgList = [];

im.Image receiptImg = im.decodePng(imageBytes);

for (var i = 0; i <= receiptImg.height; i += cropHeight) {
    im.Image cropedReceiptImg = im.copyCrop(receiptImg, 0, i, 470, 200);
        
   Uint8List bytes = im.encodePng(cropedReceiptImg);

   imgList.add(bytes);
}

imgList.forEach((element) {
  bluetooth.printImageBytes(element);
});

Read more comments on GitHub >

github_iconTop Results From Across the Web

POS Thermal Receipt Printer Troubleshoot - Not Printing Evenly
This is a troubleshooting video brought to you by Sintel Systems. This video is for a Thermal Receipt Printer. This video will explain...
Read more >
Bitmap Printing | Mini Thermal Receipt Printers
This printer can produce bitmaps, which can add a touch of class to a receipt with your logo or similar. The first step...
Read more >
Thermal Printer Protocols for Image and Text - Visuality
In order to print an image on the thermal printer, you have to process the image pixel by pixel using ESC/POS, which is...
Read more >
Print image on center position on the Thermal Printer
Hi, I am interfacing RP203 Thermal Printer from PIC16F1938 using TTL. I can print text, barcodes and images on the Thermal Printer.
Read more >
Printing an Image with textwrapping and Alignment in ESC ...
But this printer cannot print the Korean font since there is no Korean font in it. Furthermore, there is no time, so I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found