<?php
use Mike42\Escpos\Printer;
class Impresion extends CI_Controller {
    
    
    public function index() {
        try {
            $this->load->library("EscPos.php");            
                // Enter the share name for your USB printer here
               $connector = new \WindowsPrintConnector("Receipt Printer");
                /* Print a "Hello world" receipt" */
                $printer = new Escpos\Printer('epson');
                $printer -> text("Hello World!\n");
                $printer -> cut();
                $printer -> close();
        } catch (Exception $e) {
            echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
        }
    }

    public function prueba() {
        try {
            $this->load->library('ReceiptPrint');
            $printer = $this->receiptprint->connectUsb(
            'epson', 
            'CYBERIA1', 
            '12345678', 
            'epson');
            /* Initialize */
            $printer->initialize();
            $printer->feed(1);
            $printer->text("----------------------------------------\n");
            $printer->cut(Printer::CUT_FULL, 3); //corta el papel
            $printer->pulse(); // abre la caja registradora
            /* Close printer */
            $printer->close();

        } catch (Exception $e) {
            echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
        }
    }
    
}
