DantSu / ESCPOS-ThermalPrinter-Android

Useful library to help Android developpers to print with (Bluetooth, TCP, USB) ESC/POS thermal printer.
MIT License
1.22k stars 370 forks source link

SUNMI Printer prints " r" at the beginning of text #471

Closed YESMAD123 closed 10 months ago

YESMAD123 commented 11 months ago

Hi DantSu,

" r" (r with two " " before it) will be printed at the beginning of text each time I printed something. It only happened at the SUNMI inner printer connected with Bluetooth.

I have tried all the ways in the thread #258 (Create MyEscPosPrinterCommands extends EscPosPrinterCommands, and comment the line 'this.printerConnection.write(textColor);' in EscPosPrinterCommands.java) but none of them worked. Could you help to fix the problem?

WhatsApp Image 2023-11-22 at 16 35 40

DantSu commented 11 months ago

I think your printer is not compatible with many ESC POS command. Try to change size, make bold, black background, and many other option that a standard ESP POS printer do, and show me the result.

YESMAD123 commented 11 months ago

The black background white text does not work (it does not matter), below are the examples:

WhatsApp Image 2023-11-22 at 19 05 12

WhatsApp Image 2023-11-22 at 19 05 28

DantSu commented 11 months ago

ok so this is the black background initialization that write the r. You have to remove command from EscPosPrinterCommands class.

    public static final byte[] TEXT_COLOR_BLACK = new byte[]{0x1B, 0x72, 0x00};
    public static final byte[] TEXT_COLOR_RED = new byte[]{0x1B, 0x72, 0x01};

    public static final byte[] TEXT_COLOR_REVERSE_OFF = new byte[]{0x1D, 0x42, 0x00};
    public static final byte[] TEXT_COLOR_REVERSE_ON = new byte[]{0x1D, 0x42, 0x01};

Two solutions :

OR

    public static final byte[] TEXT_COLOR_BLACK = new byte[0];
    public static final byte[] TEXT_COLOR_RED = new byte[0];

    public static final byte[] TEXT_COLOR_REVERSE_OFF = new byte[0];
    public static final byte[] TEXT_COLOR_REVERSE_ON = new byte[0];
YESMAD123 commented 11 months ago

I tried the two solutions above but not working, so I deleted the lines of the four constants and after that I also deleted the

public static final byte[] TEXT_UNDERLINE_LARGE = new byte[]{0x1B, 0x2D, 0x02};

public static final byte[] TEXT_DOUBLE_STRIKE_OFF = new byte[]{0x1B, 0x47, 0x00};
public static final byte[] TEXT_DOUBLE_STRIKE_ON = new byte[]{0x1B, 0x47, 0x01};

but the " r" is still printed. Extra information: The SUNMI printer can support sticker printing.

YESMAD123 commented 10 months ago

Hi DantSu, any other solution to the " r" printing problem?

DantSu commented 10 months ago

Change your printer OR fork, remove some code and run the application. If you can't do that, don't use this library.

YESMAD123 commented 10 months ago

Alright, thank you