escpos-php icon indicating copy to clipboard operation
escpos-php copied to clipboard

Couldn't print to this printer: Failed to load image.

Open elmorsy282 opened this issue 3 years ago • 0 comments
trafficstars

i get this error

Couldn't print to this printer: Failed to load image.

<?php
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\Printer;
//use Mike42\Escpos\ImagickEscposImage;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\GdEscposImage;

try {
    $logo = new GdEscposImage("/logo.png");
    $connector = new WindowsPrintConnector("XP-80");
    //$img = EscposImage::load("logo.png", false);
    $printer = new Printer($connector);
    //$printer -> selectPrintMode();
    $printer -> setJustification(Printer::JUSTIFY_CENTER);
    $printer -> graphics($logo);
    $printer -> text("Hello World!\n");
    $printer -> cut();
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}

elmorsy282 avatar Jun 17 '22 22:06 elmorsy282