首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用字符串命令在ESC/POS中打印(Neodynamic PHP Web Client)

使用字符串命令在ESC/POS中打印(Neodynamic PHP Web Client)
EN

Stack Overflow用户
提问于 2020-10-09 20:05:59
回答 1查看 859关注 0票数 0

我正在尝试使用字符串命令剪切纸张,剪纸命令是作为0x1D 0x56给出的,但它不工作,这是一些Neodynamic PHP Web客户端的其他代码。

我到目前为止所做的,

代码语言:javascript
复制
    $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>'

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-09 21:11:24

要裁剪纸张,请使用$cmds .= $esc . "m"代替$cmds .= '0x1D 0x56';

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64279727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档