andrey-ushakov / esc_pos_utils

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

QRSize didn't work #81

Open IvanKastorsky opened 2 years ago

IvanKastorsky commented 2 years ago

No matter how I change the QRSize it still the same when printed.

Am I doing something wrong?

Printer model: Milestone MHT-P29L https://www.milestoneiot.com/?thread-21-119.html

bytes += ticket.qrcode('example', align: PosAlign.center, size: QRSize.Size2);
bytes += ticket.qrcode('example', align: PosAlign.center, size: QRSize.Size8);
bytes += ticket.qrcode('example', align: PosAlign.center, size: QRSize.Size7);
bytes += ticket.qrcode('example', align: PosAlign.center, size: QRSize(200));
fuadreza commented 1 year ago

Did you managed to solve this??

IvanKastorsky commented 1 year ago

Yes I did, but using another package

flutter_esc_pos_utils

fuadreza commented 1 year ago

I manage to solve this using image QR instead build in command qrcode.

Combined with qr_flutter

caini1213 commented 1 year ago

I manage to solve this using image QR instead build in command qrcode.

Combined with qr_flutter

hi, do u have any example of this method?

fuadreza commented 1 year ago

Hi @caini1213 , here you combine using library qr_flutter, basically you input qr image into generator image

final double qrSize = paperSize == 58 ? 250 : 300;
    try {
      final uiImg = await QrPainter(
        data: code,
        version: QrVersions.auto,
        gapless: false,
      ).toImageData(qrSize);
      final dir = await getTemporaryDirectory();
      final pathName = '${dir.path}/qr_tmp.png';
      final qrFile = File(pathName);
      if (uiImg != null) {
        final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List());
        final image = img.decodeImage(imgFile.readAsBytesSync());
        if (image != null) {
          ticket += _generator.image(image);
        }
      }
    } catch (_) {}