andrey-ushakov / esc_pos_printer

ESC/POS (thermal, receipt) printing for Flutter & Dart
BSD 3-Clause "New" or "Revised" License
351 stars 300 forks source link

PosAlign is not working.... #100

Open zakir7dipu opened 3 years ago

zakir7dipu commented 3 years ago

when I am using this "printer.text('Align center', styles: PosStyles(align: PosAlign.center));", the text align remain left and it takes a lots of new lines..... what should I do? My printer is Star mC-Print3 series........

emmaxCreative commented 3 years ago

Did you find a solution ?

I have the same problem .

When I add an image then everything is centered but without logo it uses only left align

emmaxCreative commented 3 years ago

I found out you can use to center align by sending raw data

printer.rawBytes([
      0x1B,
      0x61,
      0x31,
    ]);

and then if you want to go back to left align you can send

printer.rawBytes([
      0x1B,
      0x61,
      0x30,
    ]);

Maybe these commands in esc_pos_utils package are wrong? I tried forking it but somehow I was not able to use my changes.

 //Print Position
 const cAlignLeft = '${esc}a0'; // Left justification
 const cAlignCenter = '${esc}a1'; // Centered
 const cAlignRight = '${esc}a2'; // Right justification
 //Print Position
 const cAlignLeft = '$esc\x30'; // Left justification
 const cAlignCenter = '$esc\x31'; // Centered
 const cAlignRight = '$esc\x32'; // Right justification

correct me if Im wrong. Would be great to hear the author of the package (@andrey-ushakov )