質問
.NETでの印刷は初めてです。 WebBrowserコントロールに表示されるページを印刷したいと思います。どうすればいいですか?
解決
MSDNにはこれに関する記事がありますが、そのコード例は、WebBrowserコントロールを使用してWebページを表示せずに印刷する方法を示しています。 :
C#コード:
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();
}
所属していません StackOverflow