我試圖在拉拉維爾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