By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

How to print With C/C++ to printer?

100+
P: 1,059
Hi,
I need some documentation about controlling printer in order to print text/image or what ever i need to printer using C/C++.
Os: Linux(Open Suse/ Cent OS)

Please suggest me some link

Best Regards,
Johny
Dec 1 '10 #1
Share this Question
Share on Google+
9 Replies


Oralloy
Expert 100+
P: 983
johny10151981,

You really don't want to directly drive printers, if you don't have to.

Also, binding yourself to a vendor specific I/O libraray is probably unwise in the long run.

I'd suggest that you generate .PDF (Adobe Acrobat) files, and use one of the standard printer drivers to handle the conversions. Also, I've not had to do a lot of prettyprinting under Linux recently, so there may be technologies that I'm not familiar with - google/yahoo is your friend....

Good Luck - this sounds like a lot of fun.

Please let us know what you come up with.

Cheers!
Oralloy
Dec 1 '10 #2

100+
P: 1,059
Oralloy,
Thanks for your reply.
In fact I have done all reports with PDF. But problem is there is some lazy users for whom i have to think this way.

The fact is Most of the issue is solved. But PDF is not helping in few issues. Like paper size. According to Adobe Acrobat documentation I tried to fix the paper size. But It is not working at all. Not getting any help either. Now I need to print some data in some specific Paper position. The software is being developed as web application (No external interaction). All printers are internal. The users are so lazy that they are not interested to fix the paper size before printing(And this is not their fault). So my evil plan is to make a external library for PHP using which The required voucher will be printed directly from Server not from the user station. That is why I was looking for a solution. If the server was Windows then it would be easier for me. Cause There is some API library provided for printing without dealing with printer hardware details.

Or if there is a better plan please let me know
Dec 2 '10 #3

Oralloy
Expert 100+
P: 983
johny,

It seems to me that there are utilities for configuring Linux printers, but I'm familiar enough with them to help you.

If you've got your output being piped through lpr or a similar utility, perhaps you can extract the sizing and positioning information from the .PDF files and use that as parameters to the command?

Good Luck!
Oralloy
Dec 2 '10 #4

100+
P: 1,059
The printer server is a Windows machine(working for long time). Web server is a linux machine(Newly installed). But If Printing from command line is available in that case I will be able to print them cause. In that case I wont deal with PDF. Cause I have few lines and a circle to print that individual document And I know all the sizing and position. If you help me, it will be great. :)
Dec 2 '10 #5

Oralloy
Expert 100+
P: 983
Johny,

You can shell out command lines from your code using system() calls or a combination of fork() and exec().

Do you know how to use them?

Cheers!
Dec 2 '10 #6

100+
P: 1,059
Yes I know them. But I still need the documentation.:)
Dec 3 '10 #7

100+
P: 1,059
Orally,
Thanks for your reply. I will study them.

And the plan is changed. Right now I am developing an Desktop application using C++. Which will communicate with HTTP server. connect with it with authentication and then get required data from HTTP server and finally print will be generated from user station according to user choice. The development would be faster If I can simply use C# or old dumb Visual Basic 6. But C++ is the cheaper one
Dec 5 '10 #9

Oralloy
Expert 100+
P: 983
Johny,

Good luck with it. I know that C# and VB come with a lot of higher-functionality out of the box, however there is a huge C++ eco-system out there that you can tap into. I'm pretty sure most of what you need you can download good examples of.

Luck!
Oralloy
Dec 6 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.