我试图在拉拉维尔5.4餐厅做web应用程序。 但我不知道如何使用热敏打印机打印收据。 请建议我最好的方式来打印laravel中的热敏打印机的数据。如何在laravel 5.4中使用热敏打印机?
在此先感谢。
我试图在拉拉维尔5.4餐厅做web应用程序。 但我不知道如何使用热敏打印机打印收据。 请建议我最好的方式来打印laravel中的热敏打印机的数据。如何在laravel 5.4中使用热敏打印机?
在此先感谢。
可以使用window.print()
这里是热敏打印机在我的发票打印代码
<p align="center"><input type="button" id="pr" value="Print" onclick="printpage()" class="btn btn-success" /></p>
<script type="text/javascript">
function printpage() {
var printButton = document.getElementById("printingDiv");
printButton.style.visibility = 'hidden';
document.title = "";
document.URL = "";
window.print();
printButton.style.visibility = 'visible';
}
</script>
我最近使用Mike42/escpos的PHP我minithermal M-58 POS打印机。这是一个php插件,它将通过网络将您的php应用程序与高分辨率打印机连接起来。这是我用简单的代码在热敏打印机上打印一些文字。
try {
// Enter the share name for your USB printer here
//$connector = "POS-58";
//$connector = new WindowsPrintConnector("POS-58");
$connector = new WindowsPrintConnector("smb://yourPrinterIP");
/* Print a "Hello world" receipt" */
$printer = new Printer($connector);
/* Name of shop */
$printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH);
$printer->setJustification(Printer::JUSTIFY_CENTER);
$printer->text("POS Mart\n");
$printer->selectPrintMode();
$printer->text("Today Closing.\n");
$printer->feed();
/* Title of receipt */
$printer->setEmphasis(true);
$printer->feed(2);
/* Cut the receipt and open the cash drawer */
$printer->cut();
$printer->pulse();
/* Close printer */
$printer->close();
// echo "Sudah di Print";
return true;
} catch (Exception $e) {
$message = "Couldn't print to this printer: " . $e->getMessage() . "\n";
return false;
}
所有你需要的是您的打印机IP地址添加到你的PHP代码printconnector或者如果您使用USB线连接到打印机上,您可以使用自己的IP作为PHP代码printconnector。
试试这段代码: $ connector = new WindowsPrintConnector(“smb:// computername/Receipt Printer”);
感谢您的回复。我会尝试这一个。 – user3283395