ekasetiawans / flutter_bluetooth_printer_plugin

MIT License
26 stars 53 forks source link

addFeeds doesn't work on paper size mm58 #58

Closed u-sour closed 1 month ago

u-sour commented 1 month ago

@ekasetiawans any idea about this problem? It works on paper size mm80.

ekasetiawans commented 1 month ago

does it happen on all platforms or just certain ones?

u-sour commented 1 month ago

@ekasetiawans Yeah, both on iOS and Android.

ekasetiawans commented 1 month ago

It seems not all devices using same ESC/POS code for new feeds try to change the Commands.lineFeed here to other line feeds commands

here is permalink https://github.com/ekasetiawans/flutter_bluetooth_printer_plugin/blob/4fa875b69b2f0b801cead7a8de71470b0c0fcf77/packages/flutter_bluetooth_printer/lib/src/flutter_bluetooth_printer_impl.dart#L116

ekasetiawans commented 1 month ago

https://escpos.readthedocs.io/en/latest/commands.html

you can trying to use Carriage Return

u-sour commented 1 month ago

@ekasetiawans, Okay, after I test and change some line, here's what I founded: Command Line Feed works on printer mm80 but doesn't work mm58, and Command Carriage Return works on printer mm58 but doesn't work on mm80.

Here is what I changed If this change's ok for you. I will push all of this for you:

command.dart

  static const List<int> lineFeed = [0x0A];
  static const List<int> carriageReturn = [0x0D];

flutter_bluetooth_printer_impl.dart

 final additional = paperSize == PaperSize.mm58
          ? <int>[
              for (int i = 0; i < addFeeds; i++) ...Commands.carriageReturn,
            ]
          : <int>[
              for (int i = 0; i < addFeeds; i++) ...Commands.lineFeed,
            ];

Test Result (IOS & Android)

Printer mm80

https://github.com/user-attachments/assets/536bf2d3-675e-4f3a-a686-1a42a7abd282

Printer mm58

https://github.com/user-attachments/assets/26dcbed1-990d-4f84-bdcb-9844ec0c0961

u-sour commented 1 month ago

hi, bro @ekasetiawans can you confirm this ? Is it okay or not? I will push this pull request for you.

ekasetiawans commented 1 month ago

looks good

u-sour commented 1 month ago

@ekasetiawans Okay, bro, here: https://github.com/ekasetiawans/flutter_bluetooth_printer_plugin/pull/59 and i close this issue.