Изменить арабские буквы, напечатанные с помощью термопринтера - PullRequest
0 голосов
/ 10 июля 2019

Мне удалось напечатать арабские строки на термопринтере.Однако символы меняются местами (пишутся слева направо, а не справа налево).Я решил это, инвертировав символы строки, и все получилось.Теперь у меня есть новая проблема, потому что некоторые символы в конце арабских слов имеют неправильную форму, как на прилагаемой фотографии.

enter image description here

Как мне это решить?

Слово в первой строке должно быть "السلام", а не как показано.

Правильное слово во второй строке должно быть "النوع", а не как показано.

Это мой код для печати

 void sendData() throws IOException {
        try {
            byte[] ALLINEA_CT = {0x1B, 0x61, 0x01}; //text to center

            String title = new StringBuilder("السلام").reverse().toString()+ '\n';
            mmOutputStream.write(ALLINEA_CT);
            mmOutputStream.write(title.getBytes("ISO-8859-6"));


            String kind =new StringBuilder("النوع").reverse().toString();
            String number = new StringBuilder("العدد").reverse().toString();
            String cost = new StringBuilder("التكلفة").reverse().toString();
            String BILL = "";
            BILL = BILL+ "-----------------------------\n";
            BILL = BILL + String.format("%1$4s %2$4s %3$17s",cost,number,kind);
            mmOutputStream.write(BILL.getBytes("ISO-8859-6"));


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Вот как устанавливается соединение

      OutputStream mmOutputStream;
      InputStream mmInputStream;
      BluetoothAdapter mBluetoothAdapter;
      BluetoothSocket mmSocket;
      BluetoothDevice mmDevice;


void findBT() {

        try {
            mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

            if(mBluetoothAdapter == null) {

            }

            if(!mBluetoothAdapter.isEnabled()) {
                Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(enableBluetooth, 0);
            }

            Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();

            if(pairedDevices.size() > 0) {
                for (BluetoothDevice device : pairedDevices) {

                    if (device.getName().equals(printername)) {
                        mmDevice = device;
                        break;
                    }
                }
            }


        }catch(Exception e){
            e.printStackTrace();
        }
    }



    // tries to open a connection to the bluetooth printer device
    void openBT() throws IOException {
        try {

            // Standard SerialPortService ID
            UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
            mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid);
            mmSocket.connect();
            mmOutputStream = mmSocket.getOutputStream();
            mmInputStream = mmSocket.getInputStream();


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...