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

177 Views Asked by At

Whenever I try to execute the print order function for testing purposes I get the following error

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

My code is below (Laravel)

use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\Printer;
public function printorder()
    {
          // $connector = null;
          $connector = new WindowsPrintConnector("Black Copper BC-85AC");
          $printer = new Printer($connector);
              try {
          /* Print a "Hello world" receipt" */
          $printer->text("Hello World!");
          $printer->cut();
          $printer->close();
              } catch (Exception $e) {
          echo "Couldn't print to this printer: ". $e -> getMessage();
              }
    }

What can I try to fix this?

0

There are 0 best solutions below