热敏打印机图像无法打印mike42 escpos-php

时间:2018-07-02 15:35:46

标签: php thermal-printer escpos

实际上,我正在使用escpos-php热敏打印机mike42库,但是图像显示不正常,但是当我使用以下代码时,正在打印一些垃圾:

下面的代码正在打印垃圾,不确定原因。

<?php
date_default_timezone_set("Asia/Karachi");
/* Change to the correct path if you copy this example! */
require __DIR__ . '/../../autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;

/* Most printers are open on port 9100, so you just need to know the IP 
 * address of your receipt printer, and then fsockopen() it on that port.
 */
try {
    $connector = new NetworkPrintConnector("10.10.10.6", 9100);

    /* Print receipt" */
    $printer = new Printer($connector);


/* Start the printer */
$logo = EscposImage::load("resources/cafechox.png", false);
$printer = new Printer($connector);

/* Print top logo */
$printer -> setJustification(Printer::JUSTIFY_CENTER);
$printer -> graphics($logo);



    $printer -> cut();

    /* Close printer */
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}

0 个答案:

没有答案