esc_pos_utils icon indicating copy to clipboard operation
esc_pos_utils copied to clipboard

[TM-m30] Text alignment issue

Open jbrechbuehl opened this issue 4 years ago • 8 comments

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: image

Version: esc_pos_printer: ^3.2.4

jbrechbuehl avatar Jun 24 '20 16:06 jbrechbuehl

Probably related to #9

jbrechbuehl avatar Jun 24 '20 16:06 jbrechbuehl

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 ?

jocelyngirard avatar Sep 10 '20 18:09 jocelyngirard

Same issue on Epson TM-T20III

johnvuko avatar Oct 03 '20 09:10 johnvuko

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

johnvuko avatar Oct 03 '20 09:10 johnvuko

Same issue for Sewoo SLK-TE323

RogierVC avatar Dec 27 '20 09:12 RogierVC

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

tantzygames avatar Dec 28 '20 05:12 tantzygames

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

ajiehust avatar Mar 05 '22 21:03 ajiehust

I have same issue, you can fix this by set style with align center first printer.setStyles(const PosStyles(align: PosAlign.center));

leanhtuan1994 avatar Dec 22 '22 09:12 leanhtuan1994