mike42 / escpos-php

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

Print connector was not finalized when using EscposImage #767

Closed mimbar closed 5 years ago

mimbar commented 5 years ago

i'm using EscposImage to print image. bu everytime i try to print, the message always show: Print connector was not finalized. Did you forget to close the printer?

I'm using laravel btw.

here is the code:

 $connector = new WindowsPrintConnector("BT");

        /* Print a "Hello world" receipt" */
        $logo = EscposImage::load("escpos-php.png", false);
        $printer = new Printer($connector);
        /* Name of shop */
        $printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH);
        $printer -> graphics($logo);
        $printer -> setTextSize(1,1);
        $printer -> text("Rumah Kopi Baretto.\n");
        $printer -> selectPrintMode();
        $printer -> text("Jl. Galunggung No. 85.\n");
        $printer -> feed();

        /* Title of receipt */
        $printer -> setEmphasis(true);
        $printer -> text("Tanggal Transaksi.\n");
        $printer -> setEmphasis(false);

        /* Footer */
        $printer -> feed(2);
        $printer -> setJustification(Printer::JUSTIFY_CENTER);
        $printer -> text("Terimakasih atas kunjungan anda.\n");
        $printer -> text("Follow Instagram kami di @rumahkopibaretto\n");
        $printer -> feed(2);
        $date = "Monday 6th of April 2015 02:56:25 PM";
        $printer -> text($date . "\n");
        /* Close printer */
        $printer -> pulse();
        $printer -> cut();
        $printer -> close();

but when i remove it i can print. but i need to print the logo/image.

mimbar commented 5 years ago

i'm using EscposImage to print image. bu everytime i try to print, the message always show: Print connector was not finalized. Did you forget to close the printer?

I'm using laravel btw.

here is the code:

 $connector = new WindowsPrintConnector("BT");

        /* Print a "Hello world" receipt" */
        $logo = EscposImage::load("escpos-php.png", false);
        $printer = new Printer($connector);
        /* Name of shop */
        $printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH);
        $printer -> graphics($logo);
        $printer -> setTextSize(1,1);
        $printer -> text("Rumah Kopi Baretto.\n");
        $printer -> selectPrintMode();
        $printer -> text("Jl. Galunggung No. 85.\n");
        $printer -> feed();

        /* Title of receipt */
        $printer -> setEmphasis(true);
        $printer -> text("Tanggal Transaksi.\n");
        $printer -> setEmphasis(false);

        /* Footer */
        $printer -> feed(2);
        $printer -> setJustification(Printer::JUSTIFY_CENTER);
        $printer -> text("Terimakasih atas kunjungan anda.\n");
        $printer -> text("Follow Instagram kami di @rumahkopibaretto\n");
        $printer -> feed(2);
        $date = "Monday 6th of April 2015 02:56:25 PM";
        $printer -> text($date . "\n");
        /* Close printer */
        $printer -> pulse();
        $printer -> cut();
        $printer -> close();

but when i remove it i can print. but i need to print the logo/image.

my mistake. works when i write file name correctly.

warmwhisky commented 1 year ago

This is happening to me. But my file names are correct. Any ideas?

jakovec commented 7 months ago

This is happening to me. But my file names are correct. Any ideas?

Did you solve this somehow? Getting the same error, only on PHP8... PHP7 works fine

warmwhisky commented 7 months ago

I don't recall how I got it working, but here is my working logo on my receipt. Btw I am using PHP 8 also.

$logo = GdEscposImage::load("images/logo.png", true);

// Print top logo
$printer->setJustification(Printer::JUSTIFY_CENTER);
$printer->bitImage($logo);
jakovec commented 7 months ago

Thank you, it seems that the Intl module is not enabled in my case.