Print rendered .aspx page to server's printer

  • Thread starter Thread starter Robin Dindayal
  • Start date Start date
R

Robin Dindayal

Does anyone know how I can print a fully rendered .aspx to the
server's printer? I know that, if I wanted to print to the client's
printer it would be easy (ie. use javascript's window.print()).

However, I need to print to the server's printer. I need to print the
fully rendered .aspx page from the codebehind .aspx.cs page to the
server's printer.

I've tried using SHDocVw.InternetExplorer and SHDocVw.WebBrowser but I
just can't seem to get it to work. Any help with this would be
greatly, greatly appreciated!

Thank you!

Regards,
Robin Dindayal, BMath
Systems Developer
Intellitech Innovations Inc.
 
This is my latest attempt at getting this to work....

------------------------------------------------------------------------

// Get the WITH type from the to moniker
Type IETipo = Type.GetTypeFromProgID("InternetExplorer.Application");

// Create the NET proxy class
Object IEX = Activator.CreateInstance(IETipo);

// Set visible true
IETipo.InvokeMember("Visible",
System.Reflection.BindingFlags.SetProperty, null, IEX, new object [] {
false });

// Call method
IETipo.InvokeMember("Navigate",
System.Reflection.BindingFlags.InvokeMethod, null, IEX, new object []
{ "http://www.google.ca" });

// Print it
Object o = null;
object [] args = {OLECMDID.OLECMDID_PRINT,
OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, o, o};
ParameterModifier[] ParamMods = new ParameterModifier [1];
ParamMods[0] = new ParameterModifier (4); // inititialize with
number of method parameters
ParamMods[0][2] = true; // set the 3rd param to be an out
param
ParamMods[0][3] = true; // set the 4th param to be an out
param
IETipo.InvokeMember("ExecWB",
System.Reflection.BindingFlags.InvokeMethod, null, IEX, args,
ParamMods, null, null);

------------------------------------------------------------------------

And here is the error message that I get...

"...
The object invoked has disconnected from its clients.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The
object invoked has disconnected from its clients.

Source Error:


Line 832: ParamMods[0][2] = true; // set the 3rd param to
be an out param
Line 833: ParamMods[0][3] = true; // set the 4th param to
be an out param
Line 834: IETipo.InvokeMember("ExecWB",
System.Reflection.BindingFlags.InvokeMethod, null, IEX, args,
ParamMods, null, null);
Line 835:
Line 836:


Source File: c:\***.cs Line: 834

Stack Trace:

[COMException (0x80010108): The object invoked has disconnected from
its clients.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters) +435
...."

Again, any help would be greatly appreciated! Thanks!
Regards,
Robin Dindayal, BMath
Systems Developer
Intellitech Innovations Inc.
 
Back
Top