Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I am using the following code to print the document.Is is working fine on Visual studio but not working on IIS.

object objMissing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Application objWord;
Microsoft.Office.Interop.Word.Document objDoc;
objWord = new Microsoft.Office.Interop.Word.Application();
object fileName = @"F:\Receipt2.doc";
objDoc = objWord.Documents.Open(ref fileName,
ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing);

object copies = "1";
object pages = "";
object range = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument;
object items = Microsoft.Office.Interop.Word.WdPrintOutItem.wdPrintDocumentContent;
object pageType = Microsoft.Office.Interop.Word.WdPrintOutPages.wdPrintAllPages;
object objTrue = true;
object objFalse = false;

objDoc.PrintOut(
ref objTrue, ref objFalse, ref range, ref objMissing, ref objMissing, ref objMissing,
ref items, ref copies, ref pages, ref pageType, ref objFalse, ref objTrue,
ref objMissing, ref objFalse, ref objMissing, ref objMissing, ref objMissing, ref objMissing);


Getting the error : Word cannot print. There is no printer installed.Please help me..

Thanks.
Posted
Comments
Bernhard Hiller 21-Jul-14 2:43am    
Why don't you install a printer on the machine where IIS runs? Then have someone pick up the paper and send it by snail-mail to the user...

1 solution

When you asked earlier on today: Printing Code working in Visual Studio not in IIS[^] and I told you that C# code is executed at the Server, not the Client, did you assume that means "only for this code"?

Because it doesn't.

Let me reiterate: You cannot print on the client printer from C# code directly. That includes Processes, Word, and everything else. Go back to the previous question, follow the link I gave you are start reading: it is not trivial to print on the client printer at all!
 
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