Java – How to Print Arabic Text to a Thermal Printer (Bixolon)

How to Print Arabic Text to a Thermal Printer (Bixolon)… here is a solution to the problem.

How to Print Arabic Text to a Thermal Printer (Bixolon)

I’m testing a Bixolon thermal printer to print data from a tablet. The tablet successfully connects to the printer via Bluetooth and can print English normally. The problem, however, is in Arabic, which prints out strange characters. I’m sure the default code page is Arabic 864 (by self-test). I don’t know how to send the correct characters. I tried converting it to hexadecimal and sending it via the code below without success. It just prints as “d8b3d984d8a …”:

text = String.format("%040x", new BigInteger(1, text.getBytes(Charset.forName("UTF-8"))));
MainActivity.mBixolonPrinter.printText(text, alignment, attribute, size, false);

I tried hexadecimal

because the printer’s documentation lists the supported code pages and a table for each character in hexadecimal. I don’t know how to fix this.

Solution

Try code page Arabic 1256 and you will get Arabic letters

Related Problems and Solutions