Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi friends I want to print file contents using C++ program. Please tell me how I can do this. I don't know anything about printer programming. Please help me to sort out this problem. I want it to perform on C++. If you can provide me code to implement it, then it will be more helpful to me.
Posted
Updated 2-Jun-10 22:38pm
v4
Comments
Niklas L 3-Jun-10 3:09am    
Could you give us a hint what you want to print? Is it text only, or do you need vector graphics? Bitmaps? Embedded documents?

There's no direct support for printing in C, or C++. In C++ you can use classes in MFC. In C, I'm not sure what you'd use. You need to be clear, is it C, or C++ ?
 
Share this answer
 
Well, you are not clear at all as which technology you are using. Are you using MFC, win32, ... ?
Anyway, take a look at this section[^] on CP. You most probably will find something useful.
 
Share this answer
 
Basically, printing means drawing to the printer's device context.
It is exactly the same as drawing to the screen.
Most of the time the code to draw to the screen is exactly the same as that used for printing.
Only the device context changes from that of the screen to the printer.
All GDI functions like TextOut, LineTo, Rectangle, Ellipse etc. can be used for printing.
 
Share this answer
 
Some printers have a built-in ftp server, to which you can upload files to be printed, and some are very sofisticated when it comes to understanding and interpret different file formats. However, doing this circumvents any spooler queues i believe. (which can be very useful at the office when you want to print on a choked printer)
 
Share this answer
 
If you are using straight C++ without MFC then take a look at this page[^] on MSDN. If you are using MFC then take a look at CPrintDialog()[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900