0

我正在尝试使用字符串命令剪纸,剪纸命令为0x1D 0x56,但它不起作用,它是 Neodynamic PHP Web Client 的其他代码吗?

我到目前为止所做的,

    $useDefaultPrinter = ($qs['useDefaultPrinter'] === 'checked');
    $printerName = urldecode($qs['printerName']);

    //Create ESC/POS commands for sample receipt
    $esc = '0x1B'; //ESC byte in hex notation
    $newLine = '0x0A'; //LF byte in hex notation
     
    $cmds = '';
    $cmds = $esc . "@"; //Initializes the printer (ESC @)
    $cmds .= $esc . '!' . '0x38'; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
    $cmds .= 'BILL'; //text to print
    $cmds .= $newLine . $newLine;
    $cmds .= $esc . '!' . '0x00'; //Character font A selected (ESC ! 0)
    $cmds .= 'COOKIES                   5.00'; 
    $cmds .= $newLine;
    $cmds .= 'MILK 65 Fl oz             3.78';
    $cmds .= $newLine;
    $cmds .= 'TOTAL                     8.78';
    $cmds .= $newLine;
    $cmds .= '0x1D 0x56'; //This is not working...Im getting character 'V' as output

    //Create a ClientPrintJob obj that will be processed at the client side by the WCPP
    $cpj = new ClientPrintJob();
    //set ESCPOS commands to print...
    $cpj->printerCommands = $cmds;
    $cpj->formatHexValues = true;
     
    if ($useDefaultPrinter || $printerName === 'null') {
        $cpj->clientPrinter = new DefaultPrinter();
    } else {
        $cpj->clientPrinter = new InstalledPrinter($printerName);
    }

    //Send ClientPrintJob back to the client
    ob_start();
    ob_clean();
    header('Content-type: application/octet-stream');
    echo $cpj->sendToClient();
    ob_end_flush();
    exit();

我尝试过的几个代码是'0x1D 0x56',,$esc . '!' . '0x1D 0x56''0x1D 0x56 <m>'

4

1 回答 1

0

用剪纸$cmds .= $esc . "m"代替$cmds .= '0x1D 0x56';

于 2020-10-09T13:11:23.827 回答