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
Impresión | formatic.cat

Entradas con la etiqueta ‘Impresión’

Imprimir directo desde ms-dos. Tickets desde php bajo Windows

Jueves, 10 de Septiembre de 2009

Hace tiempo solventamos la impresión desde php a impresora de tickets bajo Linux mediante este método

Ahora tenemos la problemática de hacer lo mismo desde Windows. Existe la extensión printer pero nos interesa reutilizar la mayor parte del código, en este caso el cuerpo del ticket, para que las versiones bajo Windows y Linux difieran el mínimo posible.

Bien, siguiendo el mismo método necesitamos imprimir un fichero previamente generado desde php directamente desde consola (en este caso mediante comandos ms-dos). Ms-dos y las impresoras usb no se llevan bien, así que toca hacer un pequeño “apaño”. Mapear el puerto LPT1 a un puerto de impresión de red con nuestra impresora previamente compartida en red. Estos son los pasos:

1) Nos asegurarnos de tener, al menos, una interfaz de red. En caso de no tener ninguna podemos añadir un adaptador ficticio, como “Adaptador de bucle invertido de Microsoft” y asignarle una IP.

2) Compartimos la impresora (que por cierto, debe ser sólo texto) en red. Recordamos el nombre que le asignamos como recurso compartido.

3) Mapeamos el puerto desde ms-dos con el siguiente comando: NET USE LPT1: \\[nombre_en_red_de_la_maquina]\[nombre_impresora] /PERSISTENT:YES

4) Ahora desde php ya podemos imprimir el fichero que queramos con: shell_exec(’type nombre_fichero>lpt1′);

Con un pequeño if que detecte el sistema operativo en que está instalado php podemos tener un sistema de impresión de tickets multiplataforma. Eso si, con nuestra intervención para mapear el puerto.