0

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>'

Paul Baiju
  • 419
  • 7
  • 20
  • As you see the "V" (which is ascii 0x56) that suggests the lead-in is not working. Could the print driver be stripping it out? – droopsnoot Oct 09 '20 at 12:15
  • The documentation for ESC/POS suggests there should be a further character after the V, to indicate full cut, partial cut, feed paper to position and then full or partial cut, and a few others. Some more information in the links from here: https://stackoverflow.com/questions/15624134/how-to-use-ms-dos-commands-to-cut-paper-using-esc-pos-commands – droopsnoot Oct 09 '20 at 12:21
  • @droopsnoot I don't think its the issue of the driver, I was able to cut paper while printing the PDF demo from the save provider (neodynamic) – Paul Baiju Oct 09 '20 at 12:22
  • @droopsnoot I tried adding ``, it just prints `V ` or `V m` – Paul Baiju Oct 09 '20 at 12:29
  • 1
    But the "m" isn't an "m", it's a value. Look at the PDF linked to from that SO post, the second link in the original question, that tells you what value to send to it. For example you might send it 0x1d 0x56 0x42 0x00. But if the V is showing, that suggests it doesn't like the 0x1d lead-in. Can you find out exactly what's in the PDF demo? On some printers you can send ESC i or ESC m to just do a partial cut. – droopsnoot Oct 09 '20 at 12:45
  • I tries with value for m it does not work. but as you suggested i did `$esc . "m"`, worked like a charm. Thank you – Paul Baiju Oct 09 '20 at 12:55
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/222780/discussion-between-paul-baiju-and-droopsnoot). – Paul Baiju Oct 09 '20 at 13:06

1 Answers1

0

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

Paul Baiju
  • 419
  • 7
  • 20