esc_pos_utils
esc_pos_utils copied to clipboard
[TM-m30] Text alignment issue
Hello,
I'm having a text alignment problem with my EPSON TM-m30 printer.
With the following code, both lines are left aligned:
final CapabilityProfile profile = await CapabilityProfile.load();
final PrinterNetworkManager printerManager = PrinterNetworkManager();
printerManager.selectPrinter('192.168.1.49', port: 9100);
final Ticket ticket = Ticket(PaperSize.mm80, profile);
ticket.text('Text center', styles: PosStyles(align: PosAlign.center));
ticket.text('Text left', styles: PosStyles(align: PosAlign.left));
ticket.cut();
PosPrintResult result = await printerManager.printTicket(ticket);
print('Print result: ${result.msg}');
Result:
Version: esc_pos_printer: ^3.2.4
Probably related to #9
Hello,
I confirm this issue, reproduced on my TM-M30, the alignment parameter doesn't work as expected.
Tested with esc_pos_printer: ^3.2.4
.
Any advice to fix this problem ?
Same issue on Epson TM-T20III
Here the documentation for Epson printers: https://www.epson-biz.com/modules/ref_escpos/index.php?content_id=58
It looks for with what is done here https://github.com/andrey-ushakov/esc_pos_utils/blob/master/lib/src/commands.dart#L40
Same issue for Sewoo SLK-TE323
Also here. Here are the results of some of my testing. Hopefully we can track down the cause:
https://github.com/andrey-ushakov/esc_pos_utils/issues/9#issuecomment-751578919
I have found the a solution which is working fine with my TM-T70II. You can just insert the below code after line 35.
bytes += setStyles(PosStyles().copyWith(align: styles.align));
https://github.com/andrey-ushakov/esc_pos_utils/blob/master/lib/src/generator.dart#L351
I don't know why, but compare with function printer.image and printer.text, the problem is in file of generator.dart.
btw to make my TM-T70II, the maxCharsPerLine should change to 42 / 56
return (font == null || font == PosFontType.fontA) ? 42 : 56;
https://github.com/andrey-ushakov/esc_pos_utils/blob/master/lib/src/generator.dart#L37
and PaperSize should change to 512
int get width => value == PaperSize.mm58.value ? 372 : 512;
https://github.com/andrey-ushakov/esc_pos_utils/blob/master/lib/src/enums.dart#L41
I have same issue, you can fix this by set style with align center first
printer.setStyles(const PosStyles(align: PosAlign.center));