资江热敏打印二维码指令android
2015-07-08 22:14
501 查看
非位图打印指令
// 设置对齐方式
initPrinter();
byte[] alignByte = { 0x1B, 0x61, 1 };// 0:左对齐;1:居中;2:右对齐
mBluetoothService.write(alignByte);
byte[] hb = null;
hb = conetnt.getBytes();//二维码内容
// 0x1f,0x1c,0x08,0x03,0x0a,0x00,0x30,0x31,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x0a//一个二维码指令
byte[] code2 = new byte[7 + hb.length];
code2[0] = 0x1f; // 打印二维码
code2[1] = 0x1c;
code2[2] = 0x08;
code2[3] = 0x03;
code2[4] = (byte) hb.length;
code2[5] = 0x00;
for (int i = 0; i < hb.length; i++) {
code2[6 + i] = hb[i];
}
code2[code2.length - 1] = 0x0a;// 换行
mBluetoothService.write(code2);
// 设置对齐方式
initPrinter();
byte[] alignByte = { 0x1B, 0x61, 1 };// 0:左对齐;1:居中;2:右对齐
mBluetoothService.write(alignByte);
byte[] hb = null;
hb = conetnt.getBytes();//二维码内容
// 0x1f,0x1c,0x08,0x03,0x0a,0x00,0x30,0x31,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x0a//一个二维码指令
byte[] code2 = new byte[7 + hb.length];
code2[0] = 0x1f; // 打印二维码
code2[1] = 0x1c;
code2[2] = 0x08;
code2[3] = 0x03;
code2[4] = (byte) hb.length;
code2[5] = 0x00;
for (int i = 0; i < hb.length; i++) {
code2[6 + i] = hb[i];
}
code2[code2.length - 1] = 0x0a;// 换行
mBluetoothService.write(code2);
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories