Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress about:blank in Print Output of WinForms WebBrowser

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.

like image 941
Eric J. Avatar asked Jan 13 '12 13:01

Eric J.


1 Answers

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.

like image 121
Steve Potter Avatar answered Oct 02 '22 10:10

Steve Potter