使用ESC POS在Printer Thermal中生成QRCode

时间:2019-03-15 03:55:37

标签: javascript java image qr-code pos

我有一个类似下面的脚本, 该脚本用于打印数据和QR码,我已经成功处理了数据,现在我仍在寻找如何以打印方式显示QR码。我尝试使用html脚本,但是仅出现字符串,并且也使用java函数,但仍被认为是未定义的。 请帮助我,如何生成二维码以打印形式显示。

function print(o) {
    if (jspmWSStatus()) {
        //Create a ClientPrintJob
        var cpj = new JSPM.ClientPrintJob();
        //Set Printer type (Refer to the help, there many of them!)
        if ($('#useDefaultPrinter').prop('checked')) {
            cpj.clientPrinter = new JSPM.DefaultPrinter();
        } else {
            cpj.clientPrinter = new JSPM.InstalledPrinter($('#installedPrinterName').val());
        }
        //Set content to print...
        //Create ESP/POS commands for sample label
        var esc = '\x1B'; //ESC byte in hex notation
        var newLine = '\x0A'; //LF byte in hex 

        var cmds = esc + "@"; //Initializes the printer (ESC @)
        cmds += esc + '!' + '\x38'; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
        cmds += 'PRUDENTIAL'; //text to print
        cmds += newLine + newLine;
        cmds += esc + '!' + '\x00'; //Character font A selected (ESC ! 0)
        cmds += '<?=$qrcode?>';
        cmds += newLine + newLine;
        cmds += esc + '!' + '\x00'; //Character font A selected (ESC ! 0)
        cmds += 'ID : ' + '<?=$id?>';
        cmds += newLine;
        cmds += 'AGENT CODE : ' + '<?=$agent_code?>';
        cmds += newLine;
        cmds += 'NAME : ' + '<?=$agent_name?>';
        cmds += newLine;
        cmds += 'ACHIEVEMENT : ' + '<?=$achievement?>';
        cmds += newLine + newLine;
        cmds += esc + '!' + '\x18'; //Emphasized + Double-height mode selected (ESC ! (16 + 8)) 24 dec => 18 hex
        cmds += '# ITEMS SOLD 2';
        cmds += esc + '!' + '\x00'; //Character font A selected (ESC ! 0)
        cmds += newLine + newLine;
        cmds += '11/03/13  19:53:17';

        cpj.printerCommands = cmds;
        //Send print job to printer!
        cpj.sendToClient();
    }
} 

0 个答案:

没有答案