佳博打印机标签 Android打印

s82575289 2016-08-27 02:48:28
int ret1 =mGpService.openPort(0, PortParameters.ETHERNET, address, port);
int status = mGpService.queryPrinterStatus(0,500);
String str1 = new String();
if (status == GpCom.STATE_NO_ERR) {
str1 = "打印机正常";
} else if ((byte) (status & GpCom.STATE_OFFLINE) > 0) {
str1 = "打印机脱机";
} else if ((byte) (status & GpCom.STATE_PAPER_ERR) > 0) {
str1 = "打印机缺纸";
} else if ((byte) (status & GpCom.STATE_COVER_OPEN) > 0) {
str1 = "打印机开盖";
} else if ((byte) (status & GpCom.STATE_ERR_OCCURS) > 0) {
str1 = "打印机出错";
}
TscCommand tsc = new TscCommand(60, 40, 2);// 设置标签尺寸宽度、高度、间隙
tsc.addReference(0, 0); // 设置原点坐标
tsc.addSpeed(SPEED.SPEED1DIV5);// 设置打印速度
tsc.addDensity(DENSITY.DNESITY15);// 设置打印浓度
tsc.addDirection(DIRECTION.FORWARD);// 设置打印方向
tsc.addCls();// 清除打印缓冲区
tsc.addText(20, 20, FONTTYPE.FONT_CHINESE, ROTATION.ROTATION_0,
FONTMUL.MUL_2, FONTMUL.MUL_3," "+content[1]+" "+tableno);// 绘制文字
tsc.addText(20, 120, FONTTYPE.FONT_CHINESE, ROTATION.ROTATION_0,
FONTMUL.MUL_2, FONTMUL.MUL_3, " "+content[2]+" "+content[4]);
tsc.addText(20, 220, FONTTYPE.FONT_CHINESE, ROTATION.ROTATION_0,
FONTMUL.MUL_2, FONTMUL.MUL_3, " "+content[i]);// 绘制文
tsc.addPrint(1, 1);// 加入打印标签命令
tsc.addSound(2, 100); // 蜂鸣器
Vector<Byte> Command = new Vector<Byte>(4096, 1024);
Command = tsc.getCommand();// 获取上面编辑的打印命令
Byte[] Bytes = Command.toArray(new Byte[Command.size()]);
byte[] bytes = ArrayUtils.toPrimitive(Bytes);
String str = Base64.encodeToString(bytes, Base64.DEFAULT);
//tsc.queryPrinterStatus();

int rel = mGpService.sendTscCommand(0, str);

GpCom.ERROR_CODE r=GpCom.ERROR_CODE.values()[rel];
if(r != GpCom.ERROR_CODE.SUCCESS){

}


为什么不能打印????
...全文
952 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
疯子学炒股 2017-09-19
  • 打赏
  • 举报
回复
问题解决没,求demo

80,361

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧