1

我有一个像下面这样的脚本,这个脚本是用来打印数据和二维码的,我已经成功处理了数据,现在我还在寻找如何在打印中显示二维码。我尝试过使用 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();
    }
} 
4

0 回答 0