
            <?php
        
            require "plugins/escpos/autoload.php";
            
            use Mike42\Escpos\Printer;
            use Mike42\Escpos\EscposImage;
            use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
            use Mike42\Escpos\CapabilityProfile;
            use Mike42\Escpos\CapabilityProfiles\StarCapabilityProfile;
        
            $connector = new WindowsPrintConnector($nombreTicketera);
        
            $profile = StarCapabilityProfile::getInstance();
            $printer = new Printer($connector, $profile);
            
            /* Initialize */
            $printer->initialize();
            
            /* Font modes */
            $modes = array(
                Printer::MODE_FONT_B,
                Printer::MODE_EMPHASIZED,
                Printer::MODE_DOUBLE_HEIGHT,
                Printer::MODE_DOUBLE_WIDTH,
                Printer::MODE_UNDERLINE
            );
            
            $justification = array(
                Printer::JUSTIFY_LEFT,
                Printer::JUSTIFY_CENTER,
                Printer::JUSTIFY_RIGHT
            );
            
            $mode |= $modes[6];
            
            $printer->selectPrintMode($mode);
            $connector->write(Printer::GS . "L" . chr(0) . chr(0));
        
            $printer->setFont(Printer::FONT_B);
            $printer->setTextSize(1, 1);
            $printer->setJustification(Printer::JUSTIFY_CENTER); // centrado
            if($mostrarImagen == true){
                try {
                    //$logo = EscposImage::load("img/logo_hrl_ticket.png");
                    $logo = EscposImage::load($img_file);
                    $printer->bitImage($logo);
                } catch (Exception $e) {/*No hacemos nada si hay error*/}
            }
            $printer->text("CLINICA UNION \n");
            $printer->text("CALLE TORRES PAZ 204-230, CHICLAYO, PERU\n");
            $printer->text("RUC: 123456789     Telef: 978368886 \n\n");
            $printer->setFont(Printer::FONT_B);
            $printer->setEmphasis(false);
        
            $printer->setFont(Printer::FONT_B);
            $printer->setJustification(Printer::JUSTIFY_CENTER);
            $printer->text("============================= \n");
            $printer->text("TICKET ELECTRONICA \n");
            $printer->text("T001-000599\n");
            $printer->text("============================= \n");
            $printer->setJustification(Printer::JUSTIFY_LEFT);
            $printer->text("PACIENTE: HARY POTTER \n");
            $printer->text("DOCUMENTO IDENT.: 46525267 \n");
            
                    $printer->text("MEDICO(a): DIAZ GONZALES AUVER \n");
                    $printer->text("ESPECIALIDAD: UROLOGIA \n");
        
                    $printer->text("Fecha Emision: 10/01/2025     Hora:11:06 \n\n");
                $printer->text("CANT    DESCRIPCION                               PRECIO  \n");$printer->text("--------------------------------------------------------\n");
        $printer->text("1       CONSULTA UROLOGIA                         120.00    \n");$printer->text("--------------------------------------------------------\n");
        
            // $printer->text("---------------------------------\n");
            $printer->setJustification(Printer::JUSTIFY_LEFT);
            $printer->text("                                        SUBTOTAL  101.69\n");
            $printer->text("                                        IGV       18.31\n");
            $printer->text("                                        TOTAL     120.00\n\n");
            
            $printer->setJustification(Printer::JUSTIFY_LEFT);
            $printer->setFont(Printer::FONT_B);

            $printer->text("Cajero : usuario de prueba \n\n");
            $printer->text("Fecha/Hora de impresion: 10/01/2025 11:07:45 \n");
            $printer->setFont(Printer::FONT_A);
            $printer->text("---------------------------------\n");
                
            $printer->feed(6);
            
            $printer->cut(1);
            
            $printer->pulse();
            
            $printer->close();    
        