【问题标题】:how to set font size for bluetooth printing?如何设置蓝牙打印的字体大小?
【发布时间】:2016-11-26 06:14:05
【问题描述】:
I am writing an application which print ticket receipts.
I have some how written the code to print the receipt but the printer either      

以非常大的字体或非常小的(不可读)字体打印。 任何机构都可以为我提供设置格式的代码。

     try {
            //////////this code runs in thread
                    OutputStream os = mBluetoothSocket
                            .getOutputStream();
                    String BILL = "";
                    BILL = BILL
                            + "     *********      ";
                    BILL = BILL+"\n***Invoice No*** \n" +
                            "Muslim Movers\n"
                            +Todays_date+"\n";

                    BILL = BILL + "\n\n";
                    BILL = BILL + "Tickets:" + "      " + String.valueOf(tickets_wanted)+"\n";
                    BILL = BILL + "Price:        "+String.valueOf(Total_Tickets)+"\n"+
                            Selectedroute+"\n";
                    BILL = BILL
                            + "     *********     \n";
                    ////textsize and allignment
                    byte[] format = { 27, 33, 0 };
                    byte[] arrayOfByte1 = { 27, 3, 0 };
                    format[2] = ((byte)(0x10 | arrayOfByte1[2]));
                    format[2] = ((byte) (0x8 | arrayOfByte1[2]));
} catch (Exception e) {
                    Log.e("Main", "Exe ", e);
}
t.start();

【问题讨论】:

  • 发布您的代码以了解您做了什么

标签: android printing bluetooth thermal-printer


【解决方案1】:

在编写之前更改您的打印机配置:

  byte[] cc = new byte[]{0x1B,0x21,0x00};  // 0- normal size text
  byte[] bb = new byte[]{0x1B,0x21,0x08};  // 1- only bold text
  byte[] bb2 = new byte[]{0x1B,0x21,0x20}; // 2- bold with medium text
  byte[] bb3 = new byte[]{0x1B,0x21,0x10}; // 3- bold with large text

  outputStream.write(cc);
  outputStream.write("Your String");

【讨论】:

  • 如果我想要大而不是粗体怎么办?
  • 如果使其居中对齐并使用中等文本。有可能吗?
  • 我们只有这些有限的选择吗?如果我想让文本更大一点怎么办?
猜你喜欢
  • 1970-01-01
  • 2018-07-07
  • 2019-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多