mike42 / escpos-php

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

EPSON TM-U220 adding extra space after cut #768

Closed aliibrahimroshan closed 2 years ago

aliibrahimroshan commented 5 years ago

Hi Mike,

First of all thanks for such a use full library.its helping us alot.

I m trying the to print with EPSON TM-U220 Receipt . it is adding extra spacewhen cut and new print.. i want 2 prints at a time but it is taking too much space after cut plz see the result.

here is my code

        $connect = new WP($receipt_info['printer_name']);      
        $printer = new P($connect);

           // $printer ->feedReverse(10);
           $printer -> setJustification(P::JUSTIFY_LEFT);
           $printer -> setEmphasis(true);
           $printer -> selectPrintMode();   
           $printer -> setFont(P::FONT_B);
           $printer -> setTextSize(1, 1);
           $printer->text('0060'.'  '.'123456789');
           $printer-> text("\n");

           $printer -> cut(P::CUT_FULL, 0);

          // $printer ->feedReverse(10);
           $printer -> setJustification(P::JUSTIFY_LEFT);
           $printer -> setEmphasis(true);
           $printer -> selectPrintMode();   
           $printer -> setFont(P::FONT_B);
           $printer -> setTextSize(1, 1);
           $printer->text('0060'.'  '.'123456789');
           $printer-> text("\n");

           $printer -> cut(P::CUT_FULL, 0);

============================== Here is the result 023d27f5-23b5-4061-bd71-e46bf63e91ee

================================== With same printer but another application the result is perfect .which i want WhatsApp Image 2019-07-10 at 4 14 37 AM

Thanks :)

mike42 commented 5 years ago

Unfortunately my TM-U220B has no auto-cutter, so I can't do much to debug this on my own.

Do you have any way of determining which commands the other application is sending? If you can print it to a file or get a hexdump, then we would know for sure.

The only other alternative is to send some experimental commands, and see if you can find one to issue manually. ESC i and ESC m are candidates. On my TM-T20II, I can get cuts with no line feed via ESC i, for example, so this may be worth a shot-

$connect -> write("Hello\n\x1biWorld\n\x1bi");

Keep in mind that the cutter and print position are separated by around 27mm, so I would expect that you need to issue a cut command after already beginning the output of the next ticket. The measurements are described in the technical reference guide from Epson here.

image

aliibrahimroshan commented 5 years ago

Hi Mike,

Actaully i dont have the source code of the application that how it is cutting in the clients previous app but it working perfect on clients previous application.

aliibrahimroshan commented 5 years ago

Should give it cut command first and then text ?? or could you please explain me more about ESC i and ESC m commands that you mentioned in your reply.

Thanks you so much :)

aliibrahimroshan commented 4 years ago

incase if any one is facing the same issue i did this after wasting too much paper :) try {

        $profile = CapabilityProfile::load("default");
        $connector = new WP('EPSON DRYCLEAN');
        $printer = new P($connector, $profile);

        $printer ->selectPrintMode(P::MODE_FONT_A);

        //TAG START
        //  $printer -> selectPrintMode();
        $printer -> selectPrintMode(P::MODE_DOUBLE_HEIGHT);
        $printer-> setDoubleStrike(true);
        $printer -> text("0066             32212000000014");
        $printer->  text("\n");

        $printer->  feed();
        $connector -> write("\x1bi");

        $printer->  feed();
        $printer -> selectPrintMode();
        $printer-> setDoubleStrike(true);
        $printer -> text("SPANTIK LAB      In:3/3/2020");
        $printer->  text("\n");
        //$connector -> write("\x1bi");

        $printer -> selectPrintMode(P::MODE_DOUBLE_HEIGHT);
        $printer-> setDoubleStrike(true);
        $printer -> text("32212000000014  MON, 05:00 PM");
        $printer->  text("\n");

        $printer -> selectPrintMode();
        $printer-> setDoubleStrike(true);
        $printer -> text("3/3/2020, Pants - Lined/");
        $printer->  text("\n");

        $printer->  feed();
        $connector -> write("\x1bi");

        $printer -> selectPrintMode();
        $printer-> setDoubleStrike(true);
        $printer -> text("SPANTIK LAB       In:3/3/2020");
        $printer->  text("\n");

        $printer -> selectPrintMode(P::MODE_DOUBLE_HEIGHT);
        $printer-> setDoubleStrike(true);
        $printer -> text("32212000000014   MON, 05:00 PM");
        $printer->  text("\n");

        $printer -> selectPrintMode();
        $printer-> setDoubleStrike(true);
        $printer -> text("Extra Tag");
        $printer->  text("\n");
        $printer->  feed();
        $printer->  feed();
        $connector -> write("\x1bi");

        //TAG END
       // $connector -> write("\x1bi");
        $printer -> cut(P::CUT_FULL,1);
        $printer -> close();

        $printer_result = 'success';
    }
    catch(Exception $e)
    {
        $printer_result = 'failed';
       // $printer_result = $e -> getMessage();
    }

WhatsApp Image 2020-03-04 at 4 07 40 AM

johnygeorge commented 3 years ago

Hi , Im junior windows application developer Im having the same issue, some space is waste by auto feed, im also looking for laundry Tag print by using tm u220, by using windows form application can anybody help me to get a solution ,