471,338 Members | 1,301 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 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 5884
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Jody Gelowitz | last post: by
1 post views Thread by hellohez | last post: by
3 posts views Thread by John Peterson | last post: by

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.