printing a IHTMLDocument2 in c# WITHOUT a dialog box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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:

Code:
//Navigate to about:blank to initialise the IHTMLDocument2
object empty = System.Reflection.Missing.Value;
axWebBrowser1.Navigate(address_, ref empty, ref empty, ref empty, ref empty);

//stream the html code
mshtml.IHTMLDocument2 doc = axWebBrowser1.Document as mshtml.IHTMLDocument2;
doc.clear();
doc.writeln( .... some html ....);
doc.close();

//print the html
doc.execCommand("print", true, 0 ); //this shows a dialog. i.e. not what I
need

Thanks in advance...

PS I am using Visual Studio .NET 2003
 
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,
After browsing around MSDN, I found this:
http://msdn.microsoft.com/workshop/author/dhtml/reference/constants/idm_execprint_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 said:
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 said:
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:

Code:
//Navigate to about:blank to initialise the IHTMLDocument2
object empty = System.Reflection.Missing.Value;
axWebBrowser1.Navigate(address_, ref empty, ref empty, ref empty, ref
empty);

//stream the html code mshtml.IHTMLDocument2 doc =
axWebBrowser1.Document as mshtml.IHTMLDocument2;
doc.clear();
doc.writeln( .... some html ....);
doc.close();

//print the html
doc.execCommand("print", true, 0 ); //this shows a dialog. i.e. not
what I need

Thanks in advance...

PS I am using Visual Studio .NET 2003
 
Back
Top