使用字符串命令在 ESC/POS 中打印(Neodynamic PHP Web 客户端)
Printing in ESC/POS using string commands (Neodynamic PHP Web Client)
我正在尝试使用字符串命令剪纸,剪纸命令为 0x1D 0x56
,但它不起作用,是否是 Neodynamic PHP Web 客户端的其他代码。
到目前为止我做了什么,
$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>'
要裁纸使用 $cmds .= $esc . "m"
而不是 $cmds .= '0x1D 0x56';
我正在尝试使用字符串命令剪纸,剪纸命令为 0x1D 0x56
,但它不起作用,是否是 Neodynamic PHP Web 客户端的其他代码。
到目前为止我做了什么,
$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>'
要裁纸使用 $cmds .= $esc . "m"
而不是 $cmds .= '0x1D 0x56';