下面提到的代码是打印转换为 base64 的 QR 码,但只需将原始 QR 图像打印到打印机中。我应该如何修改代码让我知道。提前致谢。
import { Big } from "big.js";
import qz from "qz-tray";
// BEGIN EXTRA CODE
// END EXTRA CODE
/**
* @param {MxObject} qRCodeHelper
* @param {string} printername
* @returns {Promise.<void>}
*/
export async function JS_Print(qRCodeHelper, printername) {
// BEGIN USER CODE
qz.websocket.connect().then(() => {
return qz.printers.find(printername);
}).then((found) => {
var config = qz.configs.create(found);
var data = [
'^XA\n',
'^CF0,050^FO620,75^FDTEXT '+qRCodeHelper.get('Text')+'^FS^BQN,2,10^FO50,40',
{
type: 'raw', format: 'image',flavor: 'Base64',
data: qRCodeHelper.get('raw'),
options: { language: "ZPL" }
},
'^XZ\n'
];
return qz.print(config, data);
}).catch((e) => {
alert(e);
}).finally(() => {
return qz.websocket.disconnect();
});
// END USER CODE`
}