我最近使用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。