Suppress about:blank in Print Output of WinForms WebBrowser

谁说我不能喝 提交于 2019-12-30 21:55:11

问题


I'm updating a WinForms application that uses System.Windows.Forms.WebBrowser to output some HTML content generated by the program. The solution works fine, except that about:blank is printed in the footer of each page.

Is it possible to suppress that output? Alternatively, is there a straightforward alternative for printing HTML from WinForms that does not have that issue?

The client does not want to assume the presence of any third-party software such as Excel or even a PDF reader.


回答1:


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

Silly but it's the way.



来源:https://stackoverflow.com/questions/8851626/suppress-aboutblank-in-print-output-of-winforms-webbrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!