Output to Printer

I'm new to C++ and can't believe that there's no published way to send output to a printer. This is a necessity. Can anyone help?
I think there is a way, but not standard in c++. Look up in google if there exist libraries for that.
You said you're new in c++, i think you should learn the basis first, and then learn things like this.

hannes
Communicating with external devices is not a language feature. Find out what API your operating system
gives to you, then use that API.
I've googled all over, and hardly anything to help. cout of course just goes to the screen.
My main program needs to output a lot of technical information to a printer. I could do this in Basic. But I'd have to spend too much to buy a visual new basic package and reprogram so that it would run on Vista and Windows 7. A programming system seems useless if it can't do this.
Is your printer those line dot-matrix printer or those nowadays deskjet, laserjet, watever jet printer?

In general to get nice print-out require a lot of "printing knowledge". Back in the Visual Basic days, we use Crystal Report to help us do the formatting and printing.

Nowadays the rage is to leverage on existing popular software and uses it's printing API (if it expose to outside world) to help us do the print-out. Adobe is one very popular software that can deliver very nice looking print-out. In a lot of commercial vendor product I evaluate, their technical information come in PDF format.

Again, unlike Java where we have iText, PDFBox, C++ lack some libraries for us to "talk" where we can leverage on the PDF printing features to help us do printing.

Edit: Java SDK do have Printing API but once you play around, you find you need a lot of "printing knowledge" and a few try-out program I uses give sub-optimal print-out. That is when I feel Adobe is the way to go. Their software printing gives really good print-out so I believe they maintain a dedicated team of developers on that area.
Last edited on
My printer is an HP D7560. I'm using XP as the Op. System. I tried these three lines which were suggested on a forum.

filebuf fb( "prn:" );
cout = &fb;
cout <<"testing";

This didn't work. I get an error message. Any thots?

I have started to wite such a beast - I did put up a proff of concept here:
http://www.cplusplus.com/forum/articles/
Look down the page for printer stream

I have been fiddling with it on and off since - but I still have to finalize it.
closed account (1wqDSL3A)
go to:

http://www.cplusplus.com/src/

and at the bottom of windows programs click HWPrint. If that's not what you've been looking for then sorry I can't help.

Janek566
Topic archived. No new replies allowed.