打印在横向模式下从WebBrowser控件? [英] Printing In Landscape mode from a WebBrowser control?
本文介绍了打印在横向模式下从WebBrowser控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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对象。没有办法做到这一点?谢谢!
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:
wb.DocumentCompleted += wb_DocumentCompleted;
private void wb_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e)
{
((WebBrowser)sender).Print();
}
要打印(参考添加到 Microsoft.mshtml.dll
):
To print (add the reference to Microsoft.mshtml.dll
):
mshtml.IHTMLDocument2 doc = wb.Document.DomDocument as mshtml.IHTMLDocument2;
doc.execCommand("print", showUI, templatePath);
请参阅 IHTMLDocument2.execCommand ,<一个href="http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/e3aab4dd-125d-4c2f-98ac-3f0f25d357f2"相对=nofollow> MSDN论坛问题并跟踪链接。
这篇关于打印在横向模式下从WebBrowser控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文