xGprinter装了佳博官方2.1.4版SDK,可通过蓝牙、usb、网口连接打印机,并支持自定义数据打印。
连接打印机
connect()
var gprinter = api.require('xGprinter');
gprinter.connect();
});
Android系统
可提供的1.0.0及更高版本
打印测试页
printTest()
var gprinter = api.require('xGprinter');
gprinter.printTest();
Android系统
可提供的1.0.0及更高版本
打印自定义数据(多行文本)
printMultipleText({params}, callback(ret, err))
project:
title:
rows:
isSubject:
var gprinter = api.require('xGprinter');
gprinter.printMultipleText({
title : '自定义数据',
project : ['联1','联2'],
rows : [{
text : '内容1',
style : [0,0,1,0,1], //不加粗,不倍高,倍宽,不采用下划线,使用
align : 'center',
lineHeight : 60,
image : '图片base64编码' //当text为空时使用image
}],
isSubject : true
});
Android系统
可提供的1.0.0及更高版本
打印自定义数据(打印图片)
printImage({params}, callback(ret, err))
base64:
var gprinter = api.require('xGprinter');
gprinter.printImage({
base64 : 'iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOxAAADsQBlSsOGwAAB8tJREFUeF7tm4Fu4zYQRE/9/39O4wMMqK5skqMhrR29AMXhLtrV7hu+WE7S7ef34w8fELgpgX9uujdrQ+AvAQTgINyaAALcOn6WRwDOwK0JbPs3wdu23RoGy9+DwP77PrwC3CNztnxDAAE4GrcmgAC3jp/lEYAzcGsCzTfB/KD41uej/PJH39jhTXD5WFnARYBHIBdJ+pQkgAAlY2NoFwEEcJGkT0kCCFAyNoZ2EUAAF0n6lCSAACVjY2gXAQRwkaRPSQIIUDI2hnYRQAAXSfqUJIAAJWNjaBcBBHCRpE9JAghQMjaGdhFAABdJ+pQkgAAlY2NoFwEEcJGkT0kCCFAyNoZ2EUAAF0n6lCSAACVjY2gXAQRwkaRPSQIIUDI2hnYRQAAXSfqUJIAAJWNjaBcBBHCRpE9JAghQMjaGdhFAABdJ+pQkgAAlY2NoFwEEcJGkT0kCCFAyNoZ2EUAAF0n6lCSAACVjY2gXAQRwkaR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CyLLgAAAABJRU5ErkJggg=='
});
获取打印机连接状态
getStatus(callback)
ret:
var gprinter = api.require('xGprinter');
gprinter.getStatus(function(ret) {
alert(JSON.stringify(ret));
});
如果使用蓝牙连接方式,需手机打开蓝牙。目前只支持android系统。
Android系统
可提供的1.0.0及更高版本