Discussion Locked

How to print document through C# coding?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi everybody,

Can anybody tell me how to print a document throgh C# coding.
I did using streamreader, but then document is not getting printed as it originally is.Bullets,styles,spaces are different in the print out from that in screen.

then i tried using printdialog, but a blank page is getting printed or the path of document is getting printed instead of data in document.
then i tried copying the document into a rich text box and printed it from there.

I was able to get the printout as normal, but if the document is only of RTF , the coding is working.
the coding fails 4 word documents,pdf documents,etc.

=> Is there any general coding to print any kind of document through C# .

Actually i am developing an application where user when clicks 'print' button,it should be printed.user should not be given a chance to modify printer or page settings,etc.

Thanks & Regards,
Karthik

2 replies

by cmiller5400

The reason the code is failing is because they are propriatary formats. You could create a com object of the application and load the document in the com object and use it's print methods.

This discussion is closed to new replies.