Print rendered .aspx page to server's printer

Discussion in 'ASP .Net' started by Robin Dindayal, Jul 23, 2003.

  1. 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.
    Robin Dindayal, Jul 23, 2003
    #1
    1. Advertising

  2. Re: Print rendered .aspx page to server's printer -> ExecWB gives error message, "The object invoked has disconnected from its clients."

    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.

    (Robin Dindayal) wrote in message news:<>...
    > 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.
    Robin Dindayal, Jul 25, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Maz
    Replies:
    10
    Views:
    649
    Jon Maz
    Feb 11, 2004
  2. Hose B
    Replies:
    1
    Views:
    3,886
    Scott Allen
    Jul 2, 2004
  3. =?Utf-8?B?QmlsbA==?=

    Trapping 'compile' errors when aspx page is rendered.

    =?Utf-8?B?QmlsbA==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    506
    =?Utf-8?B?QmlsbA==?=
    Mar 29, 2005
  4. Assimalyst
    Replies:
    0
    Views:
    353
    Assimalyst
    Mar 24, 2006
  5. Replies:
    3
    Views:
    1,202
    bruce barker
    Mar 21, 2008
Loading...

Share This Page