473,511 Members | 9,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print rendered .aspx page to server's printer

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.
Nov 17 '05 #1
1 4252
This is my latest attempt at getting this to work....

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

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

// 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.

ro***@robindindayal.com (Robin Dindayal) wrote in message news:<f4**************************@posting.google. com>...
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.

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1317
by: Nikolay Seksenov | last post by:
I am developing VB.Net Web application to be used in our department intranet. I created a web-based report using Crystal Reports. I would like to print the report from the web server instead of...
2
3957
by: Stephen Miller | last post by:
I have an ASPX report and I want to capture the rendered HTML and write to a file on the webserver. Several posts suggest using WebRequest to make a second call to the page, and screen-scrape the...
4
1934
by: Matt Mercer | last post by:
Hi, I have a asp .net/VB web app that does the typical submitting and retrieving from a SQL database. I am lost as to how I should create a print friendly page for the data. Here is the...
1
1421
by: MrMike | last post by:
Hi. I have an aspx page which displays data on about the top 1/3 of the page, and the remaining 2/3 of the page is blank. The page is formatted so that my users can print the page to...
0
1246
by: Kresten Buch | last post by:
Hi, I have a central webapplication with lots of clients connected to it over the internet, and some of theese clients has to do a lot of printing. This is where the fun begins. One client...
9
2723
by: Scott M | last post by:
I'm printing a directory of about 500 multi-page tifs to a high speed printer and the spooler process is killing me!!! here is a little code..... Public Function PrintImage(ByVal...
7
20672
by: Mark | last post by:
Hi, I am creating application in VB 2005. and when I print report it adds extra 0.45 cm margin on left and top, and the reason for this is physical margins of printer. Is it possible to change...
0
1493
by: developer200701 | last post by:
The following code (which is distilled down from a larger application) worked for several years previously. Now, the instant you click on the print icon within the print preview window the...
3
2384
by: mygroup | last post by:
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...
0
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7148
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.