|
-
Jul 31st, 2006, 01:01 PM
#1
Thread Starter
Fanatic Member
[Resolved][2.0]Force print in web browser control
I have a file in html that I need to open and print.
It doesn't print and it doesn't show the print dialog.
Is the problem likely to be related to the fact that I never
actually display the browser control on the screen?
I kinda want this to be done behind the scenes.
It gets the path and converts it correctly, (i.e. c://thisfolder becomes c:/thisfolder like it should)
Code:
public void PrintFile()
{
//Create a new IE control
System.Windows.Forms.WebBrowser myBrowser = new System.Windows.Forms.WebBrowser();
//Load it with file
Uri myURL = new Uri(GetDefaultPath() + "PrintThisFile.html");
myBrowser.Navigate(myURL);
myBrowser.Refresh();
//Print it
myBrowser.ShowPrintPreviewDialog();
myBrowser.Print();
//close and clean up
myBrowser.Dispose();
}//PrintFile()
Last edited by JPicasso; Aug 1st, 2006 at 07:02 AM.
Merry Christmas
-
Aug 1st, 2006, 12:04 AM
#2
Re: Force print in web browser control
Try the same thing but add the control to the form's Controls collection. If it works then you know that's the issue.
-
Aug 1st, 2006, 06:42 AM
#3
Thread Starter
Fanatic Member
Re: Force print in web browser control
Hmmm.
It's not a form. Its a separate class.
Maybe I need a form.
-
Aug 1st, 2006, 07:01 AM
#4
Thread Starter
Fanatic Member
Re: Force print in web browser control
DOH!
Apparently, one has to wait for the document to load before trying to print it.
So after I .Navigate, I put in a catch for the myBrowser.DocumentCompleted.
I print and dispose in the handler.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|