elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Duda acerca de imprimir (en impresora)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Duda acerca de imprimir (en impresora)  (Leído 2,326 veces)
Pieshna

Desconectado Desconectado

Mensajes: 6


Ver Perfil
Duda acerca de imprimir (en impresora)
« en: 6 Junio 2018, 19:58 pm »

Hola buenos dias, tardes o noches...

Queria saber si alguien me puede ayudar con un codigo para imprimir (con impresora) ya que he estado buscando pero no encuentro uno funcional para c++ :-(
Es para un proyecto final de programacion y solo me falta el que se pueda imprimir los datos, ayuda! ;)


« Última modificación: 6 Junio 2018, 20:01 pm por Pieshna » En línea

SrMcLister

Desconectado Desconectado

Mensajes: 35



Ver Perfil
Re: Duda acerca de imprimir (en impresora)
« Respuesta #1 en: 7 Junio 2018, 14:07 pm »

Buenas Pieshna.
¿Podrías dar mas detalles? SO por ejemplo, marca de impresora, puerto al que está conectada...
Un Saludo.


En línea

Código
  1. return((u.areHappy() && u.knowIt()) ? u.clapYourHands() : u.goFuckYourself());
Pieshna

Desconectado Desconectado

Mensajes: 6


Ver Perfil
Re: Duda acerca de imprimir (en impresora)
« Respuesta #2 en: 8 Junio 2018, 01:39 am »

Buenas Pieshna.
¿Podrías dar mas detalles? SO por ejemplo, marca de impresora, puerto al que está conectada...
Un Saludo.

Hola, saludos SrMcLister
Estoy usando Windows 10 y estoy programando con dev-c++, la impresora es canon (MP 280), puertos LPT1-3, USB002
En línea

ThunderCls


Desconectado Desconectado

Mensajes: 455


Coder | Reverser | Gamer


Ver Perfil WWW
Re: Duda acerca de imprimir (en impresora)
« Respuesta #3 en: 8 Junio 2018, 20:09 pm »

C++ no tiene soporte nativo para la impresion de documentos (al menos que yo sepa), la impresión está condicionada por el sistema operativo que uses, en este caso windows tiene sus drivers y un sistema de spooling, etc. Aqui tienes alguna informacion

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162861(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ff819270(v=vs.85).aspx

De cualquier forma necesitas usar las APIs que te brinda tu sistema operativo y hacer las llamadas desde tu codigo c++. He encontrado este codigo por ahi pero no se si funcionara del todo, igual te podria servir

Código
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <string.h>
  4.  
  5. void printer(char text[])
  6. {
  7.  
  8. // Bring up a dialog to choose the printer
  9. PRINTDLG pd = {0};
  10. pd.lStructSize = sizeof( pd );
  11. pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
  12. pd.nCopies=1;
  13.  
  14. // Show the printer Dialog
  15. PrintDlg( &pd );
  16.  
  17.  
  18. // Zero and then initialize the members of a DOCINFO structure.
  19. DOCINFO di = {0};
  20. di.cbSize = sizeof(DOCINFO);
  21. di.lpszDocName = "Scribble Printout";
  22. di.lpszOutput = (LPTSTR) NULL;
  23. di.lpszDatatype = (LPTSTR) NULL;
  24. di.fwType = 0;
  25.  
  26. // Begin a print job by calling the StartDoc function.
  27. StartDoc(pd.hDC, &di);
  28.  
  29. // Inform the driver that the application is about to begin sending data.
  30. StartPage(pd.hDC);
  31.  
  32. //here we put images\text or other DC things;)
  33.  
  34. //send some text
  35. TextOut(pd.hDC,800,800,text, strlen(text));
  36.  
  37.  
  38. //Lets close  the printer
  39. // Inform the driver that the page is finished.
  40. EndPage(pd.hDC);
  41.  
  42. // Inform the driver that document has ended.
  43. EndDoc(pd.hDC);
  44. }
  45.  
  46. int main ()
  47. {
  48. printer("Hello world");
  49. return 0;
  50. }

Igual puedes buscarte la vida con alguna libreria, estas por ejemplo:

https://www.gtkmm.org/es/index.html
https://developer.gnome.org/gtkmm-tutorial/unstable/sec-printing-example.html.en#sec-printing-example-simple
https://www.codeproject.com/Articles/89/Printing-Class-Library

Saludos y buena suerte
En línea

-[ "…I can only show you the door. You're the one that has to walk through it." – Morpheus (The Matrix) ]-
http://reversec0de.wordpress.com
https://github.com/ThunderCls/
Pieshna

Desconectado Desconectado

Mensajes: 6


Ver Perfil
Re: Duda acerca de imprimir (en impresora)
« Respuesta #4 en: 21 Junio 2018, 06:02 am »

C++ no tiene soporte nativo para la impresion de documentos (al menos que yo sepa), la impresión está condicionada por el sistema operativo que uses, en este caso windows tiene sus drivers y un sistema de spooling, etc. Aqui tienes alguna informacion

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162861(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/ff819270(v=vs.85).aspx

De cualquier forma necesitas usar las APIs que te brinda tu sistema operativo y hacer las llamadas desde tu codigo c++. He encontrado este codigo por ahi pero no se si funcionara del todo, igual te podria servir

Código
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <string.h>
  4.  
  5. void printer(char text[])
  6. {
  7.  
  8. // Bring up a dialog to choose the printer
  9. PRINTDLG pd = {0};
  10. pd.lStructSize = sizeof( pd );
  11. pd.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
  12. pd.nCopies=1;
  13.  
  14. // Show the printer Dialog
  15. PrintDlg( &pd );
  16.  
  17.  
  18. // Zero and then initialize the members of a DOCINFO structure.
  19. DOCINFO di = {0};
  20. di.cbSize = sizeof(DOCINFO);
  21. di.lpszDocName = "Scribble Printout";
  22. di.lpszOutput = (LPTSTR) NULL;
  23. di.lpszDatatype = (LPTSTR) NULL;
  24. di.fwType = 0;
  25.  
  26. // Begin a print job by calling the StartDoc function.
  27. StartDoc(pd.hDC, &di);
  28.  
  29. // Inform the driver that the application is about to begin sending data.
  30. StartPage(pd.hDC);
  31.  
  32. //here we put images\text or other DC things;)
  33.  
  34. //send some text
  35. TextOut(pd.hDC,800,800,text, strlen(text));
  36.  
  37.  
  38. //Lets close  the printer
  39. // Inform the driver that the page is finished.
  40. EndPage(pd.hDC);
  41.  
  42. // Inform the driver that document has ended.
  43. EndDoc(pd.hDC);
  44. }
  45.  
  46. int main ()
  47. {
  48. printer("Hello world");
  49. return 0;
  50. }

Igual puedes buscarte la vida con alguna libreria, estas por ejemplo:

https://www.gtkmm.org/es/index.html
https://developer.gnome.org/gtkmm-tutorial/unstable/sec-printing-example.html.en#sec-printing-example-simple
https://www.codeproject.com/Articles/89/Printing-Class-Library

Saludos y buena suerte

Muchas gracias lo probare y gracias también por los links con la información ;) ;-)
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Imprimir colores CMYK EN IMPRESORA RGB
Diseño Gráfico
wilkins 7 8,886 Último mensaje 9 Abril 2006, 07:53 am
por _loko_
Error al imprimir con impresora en Red !!! AYUDA
Redes
kniche1989 4 7,703 Último mensaje 28 Diciembre 2011, 23:47 pm
por kniche1989
DUDA Imprimir Tickets desde C# IMPRESORA FISCAL
.NET (C#, VB.NET, ASP)
NetStorm 1 13,400 Último mensaje 10 Mayo 2012, 09:10 am
por USLO
Imprimir en impresora ethernet
Programación C/C++
soyloqbuskas 0 2,100 Último mensaje 18 Agosto 2012, 10:20 am
por soyloqbuskas
[DUDA] Leer archivos que se van a imprimir(Impresora Física)
Programación General
ReaverZ3r0 3 2,169 Último mensaje 25 Enero 2017, 13:14 pm
por ReaverZ3r0
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines