lundi 5 avril 2021

laravel mike42/escpos-php not working for usb support printing printers

I am writing an application that will send to thermal printer using laravel

I am using printer XPRINTER XP-58IIH which is a plug and play printer

It has been installed on my local computer and can print using the test print and other programs

But I am trying to to send to the printer from my laravel app but I am getting this error

Print connector was not finalized. Did you forget to close the printer?

My code

use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;


Route::get('/', function () {

try {
   /* Print a "Hello world" receipt" */
   $connector = new WindowsPrintConnector("USB001");
   $printer = new Escpos($connector);
   $printer->text("Hello World!\n");
   $printer->cut();

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

The printer is on usb printing support. I dont know if that is the reason for the error.

Anyone who can help?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire