andrey-ushakov / esc_pos_utils

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

Print Text Size issues #138

Open shersoftgithub opened 3 months ago

shersoftgithub commented 3 months ago

when i print first time it get correct result on BPOS T2 bluetooth80mm printer second time it get large sized font. when i power off and on again the print will perfect at firs time after that it get large sized.

code : { ..................... printerManager.selectPrinter(printer);

var printerSize = '3';
PaperSize paper = PaperSize.mm80;
if (printerSize == "2") {
  paper = PaperSize.mm58;
} else if (printerSize == "3") {
  paper = PaperSize.mm80;
} else if (printerSize == "4") {
  paper = PaperSize.mm112;
} else if (printerSize == "5") {
  paper = PaperSize.mm58;
}

PosPrintResult res = await printerManager.printTicket(await test(paper)); }

Future<List> test(PaperSize paper) async { var profile = await CapabilityProfile.load(); final Generator ticket = Generator(paper, profile); List bytes = []; // printerSize = '3';

try {
  bytes += ticket.text(
    'COMAPMY NAME',
    styles: const PosStyles(
        align: PosAlign.center,
        bold: true),
  );
  bytes += ticket.text('');

  bytes += ticket.text('ADDRESS 1 XXXXX',
      styles: const PosStyles(align: PosAlign.center));

  bytes += ticket.text('ADDRESS 2 XXXXX',
      styles: const PosStyles(align: PosAlign.center));

  bytes += ticket.text('ADDRESS 3 XXXXXX',
      styles: const PosStyles(align: PosAlign.center));

  bytes += ticket.text('PH:XXXXXXXXXX',
      styles: const PosStyles(align: PosAlign.center));

  bytes += ticket.text('GSTNO : XXXXXXXXXXXXXXX',
      styles: const PosStyles(align: PosAlign.center));
  bytes += ticket.text('INVOICE',
      styles: const PosStyles(align: PosAlign.center, bold: true));

bytes += ticket.hr();
   bytes += ticket.row([
     PosColumn(
         text: 'Invoice No : B XX-XX/123',
         width: 12,
         styles: const PosStyles(align: PosAlign.left)),
   ]);
   bytes += ticket.row([
     PosColumn(
         text: 'Date : 05-04-2024  11:55 AM',
         width: 12,
         styles: const PosStyles(align: PosAlign.right)),
   ]);
   bytes += ticket.hr();
   bytes += ticket.text(
       'Bill To : CUSTOMER NAME XXXXXX',
       styles: const PosStyles(align: PosAlign.left));

   bytes += ticket.hr();
   bytes += ticket.row([
     PosColumn(text: 'Description', width: 7),
     PosColumn(text: 'Qty', width: 1),
     PosColumn(
         text: 'Price',
         width: 2,
         styles: const PosStyles(align: PosAlign.right)),
     PosColumn(
         text: 'Total',
         width: 2,
         styles: const PosStyles(align: PosAlign.right)),
   ]);
  bytes += ticket.hr();

  bytes += ticket.row([
     PosColumn(
       text: itemName,
       width: 7
     ),
     PosColumn(
       text: '1NO',
       width: 1
     ),
     PosColumn(
         text: '10',
         width: 2,
      ),
     PosColumn(
         text: '10',
         width: 2
     ),
   ]);
    --------------------
  -------------------
 bytes += ticket.feed(2);
  // bytes += ticket.cut();
  return bytes;

} catch (e, s) { bytes += ticket.feed(2); return bytes; } }

1st ok https://drive.google.com/file/d/154gUgMsWhcAe9SPWBErYS_RC0B1cvNBK/view?usp=drive_link

2nd https://drive.google.com/file/d/1ykj2S2W9EEkByZeAa0RgZIuAvC-7wHnY/view?usp=drive_link