php操作热敏打印机,如何在laravel 5.4中使用热敏打印机?

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值