Printing WebBrowser Management Content

I am brand new to printing in .NET. I would like to print the page displayed in the WebBrowser control. How to do it?

+3
c # printing
Mar 04 '09 at 11:35
source share
1 answer

MSDN has an article about this, but their code example shows how to use the WebBrowser control to print a web page without displaying it.

How to print using the WebBrowser control

C # code:

private void PrintHelpPage() { // Create a WebBrowser instance. WebBrowser webBrowserForPrinting = new WebBrowser(); // Add an event handler that prints the document after it loads. webBrowserForPrinting.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(PrintDocument); // Set the Url property to load the document. webBrowserForPrinting.Url = new Uri(@"\\myshare\help.html"); } private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e) { // Print the document now that it is fully loaded. ((WebBrowser)sender).Print(); // Dispose the WebBrowser now that the task is complete. ((WebBrowser)sender).Dispose(); } 
+6
Mar 04 '09 at 11:39
source share



All Articles