在Web Base PHP laravel应用程序上从POS打印机打印账单

时间:2018-09-03 06:21:44

标签: laravel web printing epson pos

我已经开发了基于Web的POS系统。然后,我将其托管在cpanel服务器中。我可以在本地主机上打印帐单,但不能在实时服务器中打印。我为此使用了ESC / POS打印驱动程序。您能帮我解决这个问题吗?

<?php
 public function test() {
    try {
        $connector = new WindowsPrintConnector("POS Printer");
        $printer = new Printer($connector);
        $printer->text("Hello World!");
        $printer->cut();
         $printer->close();
    } catch (Exception $e) {
        echo "Couldn't print to this printer: " . $e->getMessage();
    }
}

?>

1 个答案:

答案 0 :(得分:0)

第一个问题是,您要达到什么目标?

  1. 您是否要打印到服务器的打印机? -我在您的代码中注意到,您使用的软件包,您的服务器必须与打印机直接连接。当前没有任何打印机的连接。

  2. 您是否要打印到用户的打印机? -如果您只想使用用户的打印机进行打印,则只需渲染普通的HTML(或由于要打印帐单而将其渲染为PDF),然后在浏览器中打印该文档。