【问题标题】:Php error with library Mike 42库 Mike 42 的 PHP 错误
【发布时间】:2017-07-28 19:08:27
【问题描述】:

我已经有很多时间使用 php,但是我遇到了一个与票证打印相关的项目,事实上与此相关的库并不多,而我发现的一个叫做 mike 42 的库正在给我库中的示例存在许多问题,然后继续应用程序。问题是没有太多与可能导致的错误相关的文档。

我遇到的错误信息是:

警告:复制(\Luis_Enrique\EPSON TM-T20 Receipt):无法打开流:C:\wamp\www\Probar_Ticket\src\Mike42\Escpos\PrintConnectors\WindowsPrintConnector.php 中没有这样的文件或目录在线372

这是我的代码:

require __DIR__ . '/../autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\PrintConnectors\CupsPrintConnector;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;


// Enter the device file for your USB printer here
try {
    /* add to the printer */
    $connector = new WindowsPrintConnector("EPSON TM-T20 Receipt");

    $printer = new Printer($connector);
    /* write */
    $printer->text("Hola Mundo!\n");
    /* Cut tiket */
    $printer->cut();
    /* Close printer */
    $printer->close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e->getMessage() . "\n";
}   

错误不是在代码中,在需要特定权限的 wampserver 中,或者在尝试打印机与库无法比较的情况下,而且我认为该库缺少很多文档.或者不知道他们是否知道其他一些图书馆。?

【问题讨论】:

    标签: php printing


    【解决方案1】:

    你的问题的原因是当你实例化WindowsPrintConnector时,你需要传入共享它的打印机的名称:

    $connector = new WindowsPrintConnector("EPSON TM-T20 Receipt");
    

    显然,该名称不可用。

    https://github.com/mike42/escpos-php/blob/development/example/interface/windows-usb.php#L13-L18 尝试故障排除。

    【讨论】:

      猜你喜欢
      • 2015-04-18
      • 2018-07-28
      • 1970-01-01
      • 1970-01-01
      • 2021-03-10
      • 1970-01-01
      • 1970-01-01
      • 2022-07-14
      • 1970-01-01
      相关资源
      最近更新 更多