System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();
wb.DocumentStream = new FileStream("C:a.html", FileMode.Open, FileAccess.Read);
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
wb.Print();
I know how to set the page orientation from a PrinterDocument object, but not from a WebBrowser object. Any way to do this? Thanks!
First, I recommend you to use async event model:
To print (add the reference to
Microsoft.mshtml.dll
):See IHTMLDocument2.execCommand, MSDN forum question and follow links.