I'm trying to print a document from the code behind in ASP.NET application. It is working fine in winForms.
First attempt:
- Code: Select all
Document doc = new Document();
doc.LoadFromFile("C:\\Temp\\word.docx");
PrintDocument printDoc = doc.PrintDocument;
printDoc.Print();
doc.PrintDocument = 'doc.PrintDocument' threw an exception of type 'System.NullReferenceException'
Then I added a WinForm dialog call from your sample (what is weird in asp.net app):
- Code: Select all
PrintDialog dialog = new PrintDialog();
dialog.AllowPrintToFile = true;
dialog.AllowCurrentPage = true;
dialog.AllowSomePages = true;
dialog.UseEXDialog = true;
document.PrintDialog = dialog;
PrintDocument printDoc = document.PrintDocument;
printDoc.Print();
And now the exception is on the last line printDoc.Print() - "No printers are installed."
Printers are installed, and the same code works in console or winforms application.
Any ideas?
Thank you.