General discussion

Locked

How to print document through C# coding?

By rajkar001 ·
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

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by cmiller5400 In reply to How to print document thr ...

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.

Collapse -

Refer

by sscheral In reply to How to print document thr ...

Refer this link

http://www.java2s.com/Tutorial/CSharp/0460__GUI-Windows-Forms/1020__Print-PrintDocument.htm

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums