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();
我知道如何从 PrinterDocument 对象设置页面方向,但不知道如何从 WebBrowser 对象设置页面方向。有办法做到这一点吗?谢谢!
首先,我建议您使用异步事件模型:
wb.DocumentCompleted += wb_DocumentCompleted;
private void wb_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e)
{
((WebBrowser)sender).Print();
}
打印(添加参考Microsoft.mshtml.dll
):
mshtml.IHTMLDocument2 doc = wb.Document.DomDocument as mshtml.IHTMLDocument2;
doc.execCommand("print", showUI, templatePath);
See IHTMLDocument2.execCommand http://msdn.microsoft.com/en-us/library/aa752577%28VS.85%29.aspx, MSDN论坛问题 http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/e3aab4dd-125d-4c2f-98ac-3f0f25d357f2并点击链接。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)