如何更改打印HTML文件的打印机设置 [英] How to change printer setting for printing HTML file

查看:164
本文介绍了如何更改打印HTML文件的打印机设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我是c#的新手,我需要打印应用程序,我可以更改默认的打印机设置,以便我可以选择不同的打印机托盘打印出来的HTML文件。



这是我发现的HTML文件打印代码:

Hi all,

I'm new in c# and I need to do a printing application, can I change the default printer setting so that I can select different printer tray to print out the HTML file.

Here is the HTML file printing code that i found:

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(@"C:/Users/Administrator/Desktop/dffasadadsadadsa.html");

     // Set print preview size same as the size of winForm
     webBrowserForPrinting.Parent = this;
}        



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();
}





我可以在上面的代码中更改为打印机设置吗?谢谢



Can I change to printer setting in the code above? Thanks

推荐答案

您必须修改注册表。请参阅如何使用Visual C#.NET以编程方式更改Internet Explorer和WebBrowser控件的打印机设置 [ ^ ]。
You must modify the Registry. See How To Programmatically Change Printer Settings for Internet Explorer and WebBrowser Control by Using Visual C# .NET[^].


这篇关于如何更改打印HTML文件的打印机设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆