如何使用热蓝牙打印机格式化打印收据中的字体

时间:2017-07-16 13:55:28

标签: android printing bluetooth

我做了一个POS项目。我想打印收据。我正在使用热敏打印机zonerich。我成功打印了收据。现在,我想自定义字体。我想让出口名称更大,有一个大胆的风格,并在中心。 在我的代码中,当我尝试使用粗体格式时,它会将所有收据加粗而不仅仅是出口名称。请告诉我如何只在插座名称中制作样式以及如何更改字体大小,抱歉英文不好。谢谢你的帮助。

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 个答案:

没有答案