flutterbluetooththermal-printerbluetooth-printing

DantSu / ESCPOS-ThermalPrinter FLUTTER


I am using DantSu/ESCPOS-ThermalPrinter-Android library to print on my bluetooth printer. The library accepts data to print as a String. It uses [L][C][R] tags to left align, center align and right align the content respectively.

The content is coming from an API and I pass it straight to the print function. The problem I am facing right now is that I am trying to migrate the app to Flutter and I can't find a library that accepts the above mentioned [L][C][R] tags to print.

Is there any libraries available I can use to achieve this.

Link to the library : https://github.com/DantSu/ESCPOS-ThermalPrinter-Android


Solution

  • I've found a workaround to this problem. I replaced [L][C][R] tags with the actual byte codes used to align content in the printer. Codes I used are mentioned below

    RIGHT = '\x1Ba2'
    LEFT = '\x1Ba0'
    CENTER = '\x1Ba1'
    

    The flutter printer library used is https://pub.dev/packages/esc_pos_utils