Skip to content
Advertisement

Printing in ESC/POS using string commands (Neodynamic PHP Web Client)

I am trying to cut paper using string command, the command for paper cut is given as 0x1D 0x56, but its not working, Is it some other code for Neodynamic PHP Web Client.

What i did so far,

    $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();

Few codes i have tried are '0x1D 0x56', $esc . '!' . '0x1D 0x56','0x1D 0x56 <m>'

Advertisement

Answer

To cut paper use $cmds .= $esc . "m" instead of $cmds .= '0x1D 0x56';

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement