print html rendered page from asp .net server

  • Thread starter Thread starter mygroup
  • Start date Start date
M

mygroup

Hello Folks,
I have an asp.net application which requires to fill a form. Once the
form is completed, it should print the final page on server side (not
the client side). I tried to use SHDocVw.InternetExplorer object. It
opens up the window but it is hidden(even if it I make visible
property to True). If I given print command, it does nothing. Here is
my code.
I have added reference of Interop.SHDocVw.dll

Imports System.Threading
Try
Dim o As Object
Dim result As Object
ie.Navigate("http://localhost/Default.aspx", o, o, o, o)
ie.Visible = True
While ie.Busy
Thread.Sleep(300)
End While
ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, o, o)
Catch ex As Exception
Response.Write("<br>Error occurred<br>")
Response.Write(ex.Message)
'Response.Write("<br>" & ex.InnerException.ToString)
End Try

When I run this code, no error occurs but IE window is hidden. (In
process list it shows IE) For printing, it does not do anything.
Is there anyway I can get server side printing in asp .net?

Thanks
 
Printers are specific to account.
So if you installed printer they will be installed only under account you
logged in with.

ASP.NET runs under different account so it simply does not have printers
available.

Google "print from NT service" to find out how to setup printers for ASP.NET
account

George.
 
I have given permission to ASP .Net account to use printer but it is
not working. I can hear some sounds as if some error occurred but it
is not visible to me because IE window is not visible even if I made
Visible = True. Is there any other way around to print on server side?
 
services like asp.net can not access the desktop, so there is no way to show
a window. also no default printer is setup for a service as its running
without a standard profile.

-- bruce (sqlwork.com)
 
Back
Top