打印格式调整

2019-4-1 14:14:18      点击:
// 部分参考方法,例如字体设置,对齐方式等方法
private void test() {

int concentration = 60;// 打印浓度
StringBuilder sb = new StringBuilder();
sb.append("1234567890\n");
PrintQueue.TextData tData = mPrintQueue.new TextData();// 构造TextData实例
tData.addParam(PrintQueue.PARAM_TEXTSIZE_2X);// 设置两倍字体大小
tData.addText(sb.toString());// 添加打印内容
mPrintQueue.addText(concentration, tData);// 添加到打印队列

tData = mPrintQueue.new TextData();// 构造TextData实例
tData.addParam(PrintQueue.PARAM_TEXTSIZE_1X);// 设置一倍字体大小
tData.addParam(PrintQueue.PARAM_ALIGN_MIDDLE);// 设置居中对齐
tData.addText(sb.toString());
mPrintQueue.addText(concentration, tData);

tData = mPrintQueue.new TextData();
tData.addParam(PrintQueue.PARAM_ALIGN_RIGHT);// 设置右对齐
tData.addText(sb.toString());
mPrintQueue.addText(concentration, tData);

tData = mPrintQueue.new TextData();
tData.addParam(PrintQueue.PARAM_TEXTSIZE_1X);// 设置一倍字体大小
tData.addParam(PrintQueue.PARAM_UNDERLINE);// 下划线
tData.addText(sb.toString());
mPrintQueue.addText(concentration, tData);

tData = mPrintQueue.new TextData();
tData.addParam(PrintQueue.PARAM_ALIGN_MIDDLE);// 设置居中对齐
tData.addParam(PrintQueue.PARAM_UNDERLINE);// 下划线
tData.addParam(PrintQueue.PARAM_TEXTSIZE_2X);// 设置两倍字体大小
tData.addText(sb.toString());
mPrintQueue.addText(concentration, tData);

tData = mPrintQueue.new TextData();
tData.addText(sb.toString());// 直接添加打印内容 不设置参数
mPrintQueue.addText(concentration, tData);

mPrintQueue.printStart();// 开始队列打印

}