Open niktses opened 4 years ago
Do you have a different output?
ticket.text('Center', styles: PosStyles(align: PosAlign.center));
ticket.text('Left');
ticket.text('Right', styles: PosStyles(align: PosAlign.right));
ticket.text('Left');
Yes everything is on the left
This is what I have on an EPSON TM-T20iii with esc_pos_utils 0.4.9
Same on Epson TM-m30, sometimes. Here are some test results
printDemoReceipt() seems to print correctly. testReceipt() immediately after printDemoReceipt() prints with all text centered
testReceipt() without printDemoReceipt() prints all text left justified, event text within a row:
printer.row([
PosColumn(
text: 'Align right',
width: 12,
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2),
),
]);
testReceipt() with the image first prints all text centered, including the above row. This row prints correctly:
printer.row([
PosColumn(
text: 'Change',
width: 8,
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)),
PosColumn(
text: '\$4.03',
width: 4,
styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)),
]);
Getting same issue, when i use image PosAlign.center working but without image its not working. any solution?
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));
i have faced same issue here is the solution // Align left command in ESC/POS is ESC a 0 // ESC = 27, a = 97, 0 = left alignment bytes += [27, 97, 0]; bytes += generator.text('5552\n');
Texts are always aligned left. It is not updated through the text styling.