[英]Printing In Landscape mode from a WebBrowser control?
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. 我知道如何从PrinterDocument对象设置页面方向,但不知道如何从WebBrowser对象设置页面方向。 Any way to do this?
有什么办法吗? Thanks!
谢谢!
First, I recommend you to use async event model: 首先,我建议您使用异步事件模型:
wb.DocumentCompleted += wb_DocumentCompleted;
private void wb_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e)
{
((WebBrowser)sender).Print();
}
To print (add the reference to Microsoft.mshtml.dll
): 要打印(添加对
Microsoft.mshtml.dll
的引用):
mshtml.IHTMLDocument2 doc = wb.Document.DomDocument as mshtml.IHTMLDocument2;
doc.execCommand("print", showUI, templatePath);
See IHTMLDocument2.execCommand , MSDN forum question and follow links. 请参阅IHTMLDocument2.execCommand , MSDN论坛问题和链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.