How to format font in print receipt with thernal bluetooth printer

Viewed 1978

I make a POS project. I want to print receipt. I'm using thermal printer zonerich. I had successfully to print the receipt. Now, I want to custom the font. I want to make the outlet name bigger ,have a bold style and in center. In my code bellow, when i try to put the bold format it will bold all of the receipt not only the outlet name. Please tell me how to make style only in outlet name and how to change the font size, Sorry for bad english. Thanks for your help.

public void IntentPrint(String notaID, String namaKasir, String date, String total, String pay, String change, String method) {
            db = new DatabaseHandler(MainActivity.this);
            String payment="";
            String sosmed = "\n"+ sessionStartUp.getUserDetails().get(sessionStartUp.KEY_SOSMED);
            String namaOtlet = sessionStartUp.getUserDetails().get(sessionStartUp.KEY_OUTLET);
            String header ="\nReceipt    : " + db.getFakeNotaID(notaID) + "\n" +
                    "Nama Kasir : " + namaKasir + "\n" +
                    "Date       : " + date+"\n"+
                    "Name               Qty  Price"+"\n";
            if(!pay.equals("0"))
            {
                 payment ="\nTotal   : "+total+"\n"+"Method   : "+method+"\n"+
                                "Payment  : "+pay+"\n"+
                                "Change   : "+change;
            }
            else
                payment ="\nTotal   : "+total+"\n"+"\nMethod   : "+method+"\n";

            InitPrinter();

            try {

                outputStream.write(header.getBytes());
                outputStream.write(data(notaID).getBytes());
                outputStream.write(payment.getBytes());
                outputStream.write(sosmed.getBytes());

                byte[] format= { 27, 33, 0 };
                byte[] center =  { 0x1b, 'a', 0x01 };
                byte[] arrayOfByte1 = { 27, 33, 0 };
                format[2] = ((byte)(0x8 | arrayOfByte1[2]));


                outputStream.write(center);
                outputStream.write(format);
                outputStream.write(namaOtlet.getBytes(),0,namaOtlet.getBytes().length);

                outputStream.close();
                socket.close();
            } catch (Exception ex) {
                value += ex.toString() + "\n" + "Excep IntentPrint \n";
    //                Toast.makeText(this, value, Toast.LENGTH_LONG).show();
            }

        }
0 Answers
Related