473,378 Members | 1,415 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,378 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 6078
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.