打印WebBrowser控件的内容 [英] Printing WebBrowser control content
本文介绍了打印WebBrowser控件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我绝对新印刷的.NET。我想打印显示在WebBrowser控件的页面。我该怎么办呢?
I'm absolutely new to printing in .NET. I would like to print a page that is displayed in WebBrowser control. How do I do that?
推荐答案
MSDN有关于这方面的文章,但他们的code示例演示了如何使用WebBrowser控件不显示它打印网页。
MSDN has an article about this, however their code example demonstrates how use the WebBrowser control to print a Web page without displaying it. :
在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();
}
这篇关于打印WebBrowser控件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文