uu
This commit is contained in:
parent
b8b558daf7
commit
f9755a4222
@ -82,8 +82,44 @@ var tanexPrinter = {
|
||||
r.push((~bits[i]) & 0xFF);
|
||||
}
|
||||
tanexPrinter.addCommand('\r\n')
|
||||
// console.log('===>setBitmapCmd:',JSON.stringify(r))
|
||||
console.log('===>setBitmapCmd:', r)
|
||||
}
|
||||
|
||||
tanexPrinter.addBitmap2 = function(x, y, res) { //添加图片,res为画布参数
|
||||
var w = res.width
|
||||
var width = parseInt((res.width + 7) / 8 * 8 / 8)
|
||||
var height = res.height;
|
||||
// console.log(width + "--" + height)
|
||||
data = `EG ${width} ${height} ${x} ${y} `
|
||||
// console.log(command)
|
||||
var r = []
|
||||
var bits = new Uint8Array(height * width);
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < w; x++) {
|
||||
var color = res.data[(y * w + x) * 4 + 1];
|
||||
if (color > 128) {
|
||||
bits[parseInt(y * width + x / 8)] |= (0x80 >> (x % 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < bits.length; i++) {
|
||||
r.push((~bits[i]) & 0xFF);
|
||||
}
|
||||
let egIData = ``
|
||||
r.map(v=> {
|
||||
// 转成16位的ASCII
|
||||
let a16 = (v).toString(16)
|
||||
if(v < 16) {
|
||||
a16 = `0${a16}`
|
||||
}
|
||||
a16 = a16.toUpperCase()
|
||||
data += `${a16}`
|
||||
})
|
||||
tanexPrinter.addCommand(data)
|
||||
console.log("addBitmap2 EG data =====================", data)
|
||||
tanexPrinter.addCommand('\r\n')
|
||||
}
|
||||
|
||||
tanexPrinter.addText = function(text) {
|
||||
data = `TEXT 24 0 10 10 ${text}\r\n`
|
||||
tanexPrinter.addCommand(data)
|
||||
|
||||
@ -43,7 +43,7 @@ export default {
|
||||
imgData: '',
|
||||
percentage: 0, // 打印进度
|
||||
imageUrl: '',
|
||||
paperWidth: 320,
|
||||
paperWidth: 560,
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@ -65,10 +65,14 @@ export default {
|
||||
}
|
||||
let prtInstance = tanexPrinterUniSdk.createInstance()
|
||||
prtInstance.init(that.canvasHeight)
|
||||
prtInstance.addBitmap(0, 0, that.imgData)
|
||||
prtInstance.diyCode(`PAGE-WIDTH 600\r\n`)
|
||||
// prtInstance.diyCode(`EG 2 16 90 45 F0F0F0F0F0F0F0F00F0F0F0F0F0F0F0F`)
|
||||
// prtInstance.diyCode(`F0F0F0F0F0F0F0F00F0F0F0F0F0F0F0F\r\n`)
|
||||
// prtInstance.addBitmap2(0, 0, that.imgData)
|
||||
prtInstance.addBitmap2(0, 0, that.imgData)
|
||||
prtInstance.setPagePrint()
|
||||
let commond = prtInstance.getPrintCmd()
|
||||
console.log("打印命令组装完成,开始打印=====")
|
||||
console.log("打印命令组装完成,开始打印=====", commond)
|
||||
printModule.print(deviceId, commond, true)
|
||||
// printModule.printTestSimple(deviceId)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user