Чтобы распечатать квитанцию ​​с Bluetooth POS-принтера Thermal - PullRequest
0 голосов
/ 04 апреля 2019

Мне нужно напечатать квитанцию ​​с небольшим текстом в центре, а затем слева с маленьким текстом. Но наступает исключение из-за сломанной трубы.

    public static final byte[] INIT = {27, 64};
    public static final byte[] FEED_LINE = {10};

    public static final byte[] SELECT_FONT_A = {27, 33, 0};

    public static final byte[] FONT_B = {0x1B, 0x4D, 0x01};
    public static final byte[] ALLINEA_SX = {0x1B, 0x61, 0x00};
    public static final byte[] ALLINEA_CT = {0x1B, 0x61, 0x01};

    os.write(PrinterCommands.INIT);
    os.write(PrinterCommands.ALLINEA_CT); //text to center
    os.write(PrinterCommands.SELECT_FONT_A);
    os.write(PrinterCommands.FONT_3X);
    BILL = "XXX RESTAURANT" + "\n";
    os.write(BILL.getBytes());
    os.write("Hello stackoverflow!!\n".getBytes());
    os.write(PrinterCommands.FONT_1X);
    os.write(PrinterCommands.ALLINEA_SX); //text to left
    String BILL ="Order number: "+ orderId+"\n";
    BILL = BILL+"Order Time: "+order_time;
    BILL = "Delivery Time: "+order_delivery_time;
    os.write(BILL.getBytes());
...