为什么命令在热敏打印机中从页面中间打印



为什么热敏打印机中的命令从页面中间开始打印,以及为什么在第一张收据完成之前就被剪切了。以下是我的代码(我正在使用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

收据

这是由于打印头和切纸器之间的距离造成的。

$cmds .= '0x1D0x560x00';

本页上的函数A是您在问题文章中使用的函数
GS V

选择剪切模式并剪切纸张

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

>使用此命令,当打印机接收到该命令时,将在纸张位置切割纸张。


您应该指定函数B。

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

调整进纸量XX,以便在正确的位置切割纸张。

$cmds .= '0x1D0x560x410xXX';

最新更新