Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-settings.php on line 530

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 611

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /home/controlz/public_html/blog/wp-includes/classes.php on line 728

Strict Standards: Redefining already defined constructor for class wpdb in /home/controlz/public_html/blog/wp-includes/wp-db.php on line 306

Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-includes/cache.php on line 103

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /home/controlz/public_html/blog/wp-includes/cache.php on line 425

Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/controlz/public_html/blog/wp-includes/theme.php on line 623

Strict Standards: Redefining already defined constructor for class WP_Dependencies in /home/controlz/public_html/blog/wp-includes/class.wp-dependencies.php on line 15

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/controlz/public_html/blog/wp-settings.php:472) in /home/controlz/public_html/blog/wp-content/plugins/si-captcha-for-wordpress/si-captcha.php on line 31

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/controlz/public_html/blog/wp-settings.php:472) in /home/controlz/public_html/blog/wp-content/plugins/si-captcha-for-wordpress/si-captcha.php on line 31

Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GoogleSitemapGeneratorLoader::Enable() should not be called statically in /home/controlz/public_html/blog/wp-includes/plugin.php on line 311
Tm-u200 | formatic.cat

Entradas con la etiqueta ‘tm-u200’

Ejemplos de impresión en impresora de tickets y PHP-GTK 2

Miércoles, 13 de Agosto de 2008

Siguiendo con el trabajo utilizando PHP-GTK, y después de explicar como imprimir con impresora de tickets, ahora toca aprender algo de comandos hacia la impresora Epson TM-U200, aunque supongo que los comandos funcionarán, si no en todas las epson, en la gama TM.

Vamos a crear un ‘buffer’ de contenido a partir de un fichero PRN.

$handle = fopen(”PRN”, “w”); // note 1

A partir de ahora escribiremos sobre $handler nuestro ticket, para a posteriori imprimir ese fichero.

Comandos útiles:

fwrite($handle,chr(27). chr(64));  //->Reinicializa la impresion, esto hay que hacerlo siempre al inicio.

Alineación:
fwrite($handle, chr(27). chr(97). chr(0)); //->Izquierda
fwrite($handle, chr(27). chr(97). chr(1)); //->Centro
fwrite($handle, chr(27). chr(97). chr(2)); //->Derecha

Este comando es bastante importante, ya que por ejemplo, en las alineaciones de múltiples palabras en una misma linea, por ejemplo para hacer una columna en centro y otra en derecha, si no hay un limpiado de buffer no funciona.

fwrite($handle, chr(27). chr(100). chr(N)); //-> Limpia el buffer, y salta N lineas, poner numero de saltos en la ‘N’, admite un 0.

chr(238) -> es la numeración para escribir un símbolo parecido al Euro. (fwrite($handle, chr(238)))

Para cerrar el ‘PRN’ y imprimirlo, como explicamos en anteriores entradas:

fclose($handle); // cierra el fichero PRN
$salida = shell_exec(’lpr PRN’); //lpr->puerto impresora, imprimir archivo PRN

Básicamente con la combinación de estos comandos y sabiendo que “fwrite($handle, ‘Hola’);” es válido para escribir una frase en el ticket,creo que ya no tendréis problemas con ello.