473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

printing a IHTMLDocument2 in c# WITHOUT a dialog box

Hello there,
I am quite new to .NET development so please forgive my question if it is
trivial. I am trying to print a IHTMLDocument2 object in c# without spawning
a dialog box, because the printing must be Automated.

I have got some code to work that does it with a dialog box, but this is not
what I need. Anyway, here is a snippet of the code I have already written:

Expand|Select|Wrap|Line Numbers
  1. //Navigate to about:blank to initialise the IHTMLDocument2
  2. object empty = System.Reflection.Missing.Value;
  3. axWebBrowser1.Navigate(address_, ref empty, ref empty, ref empty, ref empty);
  4.  
  5. //stream the html code
  6. mshtml.IHTMLDocument2 doc = axWebBrowser1.Document as mshtml.IHTMLDocument2;
  7. doc.clear();
  8. doc.writeln( .... some html ....);
  9. doc.close();
  10.  
  11. //print the html
  12. doc.execCommand("print", true, 0 ); //this shows a dialog. i.e. not what I
  13. need
  14.  
Thanks in advance...

PS I am using Visual Studio .NET 2003

Jul 21 '05 #1
2 6081
Adam,
The 2nd parameter to execCommand is bUserInterface which you have set
to true. Have you tried setting it to false?

Jason Newell, MCAD
Software Engineer

Adam Hulbert wrote:
Hello there,
I am quite new to .NET development so please forgive my question if it is
trivial. I am trying to print a IHTMLDocument2 object in c# without spawning
a dialog box, because the printing must be Automated.

I have got some code to work that does it with a dialog box, but this is not
what I need. Anyway, here is a snippet of the code I have already written:

Expand|Select|Wrap|Line Numbers
  1.  //Navigate to about:blank to initialise the IHTMLDocument2
  2.  object empty = System.Reflection.Missing.Value;
  3.  axWebBrowser1.Navigate(address_, ref empty, ref empty, ref empty, ref empty);
  4.  //stream the html code
  5.  mshtml.IHTMLDocument2 doc = axWebBrowser1.Document as mshtml.IHTMLDocument2;
  6.  doc.clear();
  7.  doc.writeln( .... some html ....);
  8.  doc.close();
  9.  //print the html
  10.  doc.execCommand("print", true, 0 ); //this shows a dialog. i.e. not what I
  11.  need
  12.  

Thanks in advance...

PS I am using Visual Studio .NET 2003

Jul 21 '05 #2
Adam,
After browsing around MSDN, I found this:
http://msdn.microsoft.com/workshop/a...cprint_scr.asp

It would appear that setting bUserInterface to false will not have any
affect, but I would try it anyway. Sorry if I wasn't any help.

Jason Newell, MCAD
Software Engineer

Jason Newell wrote:
Adam,
The 2nd parameter to execCommand is bUserInterface which you have
set to true. Have you tried setting it to false?

Jason Newell, MCAD
Software Engineer

Adam Hulbert wrote:
Hello there, I am quite new to .NET development so please forgive my
question if it is trivial. I am trying to print a IHTMLDocument2
object in c# without spawning a dialog box, because the printing must
be Automated.
I have got some code to work that does it with a dialog box, but this
is not what I need. Anyway, here is a snippet of the code I have
already written:

Expand|Select|Wrap|Line Numbers
  1.  //Navigate to about:blank to initialise the IHTMLDocument2
  2.  object empty = System.Reflection.Missing.Value;
  3.  axWebBrowser1.Navigate(address_, ref empty, ref empty, ref empty, ref
  4.  empty);
  5.  //stream the html code mshtml.IHTMLDocument2 doc =
  6.  axWebBrowser1.Document as mshtml.IHTMLDocument2;
  7.  doc.clear();
  8.  doc.writeln( .... some html ....);
  9.  doc.close();
  10.  //print the html
  11.  doc.execCommand("print", true, 0 ); //this shows a dialog. i.e. not
  12.  what I need
  13.  

Thanks in advance...

PS I am using Visual Studio .NET 2003

Jul 21 '05 #3

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

Similar topics

9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
0
by: LilBuh | last post by:
Hello :) this is a repost... i ve been looking for a way since last week ... i have a template html file that i modify from my code... i need to print this file without IE's Header and Footer or...
2
by: Adam Hulbert | last post by:
Hello there, I am quite new to .NET development so please forgive my question if it is trivial. I am trying to print a IHTMLDocument2 object in c# without spawning a dialog box, because the...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
1
by: hellohez | last post by:
We are currently looking into triggering printing of an HTML file to a designated printer in such a way that the print dialog box is not viewed. It is possible to use the print method of a default...
3
by: John Peterson | last post by:
Hello all! I'm at my wits end trying to search for what I assumed to be a relatively straightforward task. I have a Web application written in C#, and I have a button on the form that I want to...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
0
by: GHS | last post by:
I'm writing code to parse a specific website and decided to use MSHTML to help (instead of regular expressions). The parsing code is complete - looks very nice if I say so myself. :-) The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.