在WinForms WebBrowser的打印输出中取消显示about:black



我正在更新一个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();
}

愚蠢,但这是方式。

最新更新