Eri*_* J. 5 .net c# printing webbrowser-control winforms
我正在更新一个WinForms应用程序,它使用System.Windows.Forms.WebBrowser来输出程序生成的一些HTML内容.解决方案工作正常,除了about:blank打印在每页的页脚中.
是否可以抑制输出?或者,是否有一个简单的替代方法来从WinForms打印没有该问题的HTML?
客户不希望假设存在任何第三方软件,如Excel甚至PDF阅读器.
public void ClearBrowserPrintHeaderAndFooter()
{
string path = "Software\\\\Microsoft\\\\Internet Explorer\\\\PageSetup";
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(path, true);
if (key == null) {
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(path, true);
}
key.SetValue("header", "");
key.SetValue("footer", "");
key.Close();
}
Run Code Online (Sandbox Code Playgroud)
傻但是这样.