mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.59k stars 863 forks source link

Notice: Print connector was not finalized. Did you forget to close the printer?Error while using mike42 #1014

Open malihaz opened 3 years ago

malihaz commented 3 years ago

Here is the complete error: Notice: Print connector was not finalized. Did you forget to close the printer? in E:\xampp\htdocs\newmike42\escpos-php\src\Mike42\Escpos\PrintConnectors\FilePrintConnector.php on line 47

Any suggestions please?

sysarp commented 3 years ago

A website error has occurred. Sorry for the temporary inconvenience.

Notice: Print connector was not finalized. Did you forget to close the printer? in /home/www/AppClient/nomade.local/backend/vendor/mike42/escpos-php/src/Mike42/Escpos/PrintConnectors/FilePrintConnector.php on line 44

##################################################################################################

        try{

            //file_put_contents("192.168.1.110:9100","Imprimiendo",FILE_APPEND);

            $connector      = new \Mike42\Escpos\PrintConnectors\NetworkPrintConnector("192.168.1.110",9100);
            //$connector        = new \Mike42\Escpos\PrintConnectors\CupsPrintConnector("POS-80");
            $printer        = new \Mike42\Escpos\Printer($connector);

            $printer->setJustification(Printer::JUSTIFY_CENTER);
            $printer->setTextSize(2, 2);

            $printer->text("Hello World!\n");
            //$printer->feed(1);
            $printer->cut();
            //$printer->pulse();
            $printer->close();

            $response->getBody()->write("Imprimiendo");
            return $response;

        }catch(Exception $e){
            echo "No se pudo imprimir en esta impresora: " . $e -> getMessage() . "\n";
        }