1

Why the commands in thermal printer start printing from the middle of the page and why it was cut before the first receipt finished. Following is my code ( I am using https://www.neodynamic.com/articles/How-to-print-raw-ESC-POS-commands-from-PHP-directly-to-the-client-printer/ )

    //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 .= 'ALGERIE TELECOM'; //text to print
$cmds .= $newLine . $newLine;
$cmds .= $esc . '!' . '0x00'; //Character font A selected (ESC ! 0)
$cmds .= 'Serial           1234567890';
$cmds .= $newLine;
$cmds .= 'PIN              12345566778';
$cmds .= $newLine . $newLine;
$cmds .= 'Face Value        129080981283';
$cmds .= $newLine;
$cmds .= 'Voucher Type      Broadband';
$cmds .= $newLine;
$cmds .= 'Mobile            Mobile';
$cmds .= $newLine . $newLine;
$cmds .= $esc . '!' . '0x18'; //Emphasized + Double-height mode selected (ESC ! (16 + 8)) 24 dec => 18 hex
$cmds .= '# ALGERIE TELECOM';
$cmds .= $esc . '!' . '0x00'; //Character font A selected (ESC ! 0)
$cmds .= $newLine . $newLine;
$cmds .= '09/29/22  19:53:17';

$cmds .= $newLine;
$cmds .= '0x1D0x560x00';
$cmds .= $newLine;

$cmds .= $esc . '!' . '0x38'; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
$cmds .= 'ALGERIE TELECOM'; //text to print
$cmds .= $newLine . $newLine;
$cmds .= $esc . '!' . '0x00'; //Character font A selected (ESC ! 0)
$cmds .= 'Serial            0987654321';
$cmds .= $newLine;
$cmds .= 'PIN               28409328385';
$cmds .= $newLine . $newLine;
$cmds .= 'Face Value        129080981283';
$cmds .= $newLine;
$cmds .= 'Voucher Type      Broadband2';
$cmds .= $newLine;
$cmds .= 'Mobile            Mobile2';
$cmds .= $newLine . $newLine;
$cmds .= $esc . '!' . '0x18'; //Emphasized + Double-height mode selected (ESC ! (16 + 8)) 24 dec => 18 hex
$cmds .= '# ALGERIE TELECOM';
$cmds .= $esc . '!' . '0x00'; //Character font A selected (ESC ! 0)
$cmds .= $newLine . $newLine;
$cmds .= '09/29/22  19:53:17

Receipts

1 Answers1

0

This is due to the distance between the print head and paper cutter.

$cmds .= '0x1D0x560x00';

Function A on this page is what you are using in your question article.
GS V

Select cut mode and cut paper

<Function A>           Executes paper cut  
   ASCII   GS  V  m  
   Hex     1D 56  m  
                  m : 0 Full cut  

With this command, the paper is cut at the paper position when the printer receives the command.


Function B is the one you should specify.

<Function B>           Feeds paper to [cutting position + (n × vertical motion unit)] and executes paper cut  
   ASCII   GS  V  m  n  
   Hex     1D 56  m  n  
                  m : 65(0x41) Full cut  
                  n : Feeds paper (n × vertical motion unit)  

Adjust the paper feed amount XX so that the paper is cut at the correct position.

$cmds .= '0x1D0x560x410xXX';
kunif
  • 4,060
  • 2
  • 10
  • 30