473,657 Members | 2,627 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6110
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
4101
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 PrintDialog control under a security setting with only SafePrinting allowed. I have attached a sample project that I am using to try to accomplish this. The print dialog appears, but when I press the Print button, I get an exception (at the end...
0
1896
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 any print dialog then once the printing's done... restore the original Header and footer but here's what happens: - save the current header and footer
2
605
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 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: //Navigate to about:blank to initialise the IHTMLDocument2
1
5704
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 of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
1
7061
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 browser and let the browser handle the output, however this pops up the print dialog box. The alternative is to handle all of the format/parsing ourselves but this seems a lot of work. As we know exactly which printer we need to send this to,...
3
3743
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 print the current contents of the browser without bringing up the print dialog. At first I thought it was a simple matter to have the button's "onclick" attribute set to "window.print();". However, that always brings up the print dialog box. ...
6
4084
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 the user wants all pages will produce 3 pages. I want to offer the user the ability to select via the print dialog that only pages 1 and 2 of it are printed or possibly pages 1 and 3 but not 2. At the moment I can produce all three pages...
0
1532
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 problem I have is setting up the doc itself. Here is a code snippet of where the problem shows up: FileStream file = new FileStream("c:\\day.html", FileMode.OpenOrCreate, FileAccess.Read); StreamReader sr = new StreamReader(file); string html =...
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7324
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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 we have to send another system
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.