Couldn't print to this printer: Failed to load image. mike42/Escpos-php

1.8k Views Asked by At

hello can anyone help me with this error Couldn't print to this printer: Failed to load image.

my code

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

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

There are 1 best solutions below

0
mahmoud On

solved ImagickEscposImage is not installed now it's working thanks Alex