mike42 / escpos-php

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

BSC-10 print image in incorrect format #840

Open CHOMNANP opened 4 years ago

CHOMNANP commented 4 years ago

I'm using this code, and the printer produce incorrect image format. Printer Model: BSC-10 (Star Printer)


use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
use Mike42\Escpos\CapabilityProfile;

        $profile = CapabilityProfile::load("simple");
        $connector = new NetworkPrintConnector("192.168.222.2", 9100);
        $printer = new Printer($connector, $profile);
        $image = Storage::disk('local')->path('public/demo.png');

        $pdf = Storage::disk('local')->path('public/demo.pdf');
        $pages = ImagickEscposImage::loadPdf($pdf);
        foreach ($pages as $page) {
           $printer->graphics($page);
         }
        $printer->cut();

Output:

image

mike42 commented 4 years ago

I did some quick research on this, and apparently a Star printer in ESC/POS mode will understand GS v 0 and ESC * commands (source applicable to the BC-10). These commands are sent by bitImage() and bitImageColumnFormat() in this library. The BC-10 does not appear to implement the command which is used by graphics().

So two things for you to do: