燮preSS有关:在web浏览器的WinForms打印输出空白 [英] Suppress about:blank in Print Output of WinForms WebBrowser

查看:174
本文介绍了燮preSS有关:在web浏览器的WinForms打印输出空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新使用System.Windows.Forms.WebBrowser输出由程序生成一些HTML内容的WinForms应用程序。该解决方案工作正常,但有关:空白打印在每一页的页脚

是否有可能燮preSS的输出?另外,有来自不具有该问题的WinForms打印HTML一个简单的方法吗?

客户端不希望承担任何第三方软件如Excel,甚至是PDF阅读器presence。

解决方案

 公共无效ClearBrowserPrintHeaderAndFooter()
{
    字符串路径=软件\\\\微软\\\\ Internet Explorer的\\\\对于PageSetup;
    Microsoft.Win32.RegistryKey键= Microsoft.Win32.Registry.CurrentUser.OpenSubKey(路径,真实);
    如果(关键== NULL){
        键= Microsoft.Win32.Registry.LocalMachine.OpenSubKey(路径,真实);
    }
    key.SetValue(头,);
    key.SetValue(页脚,);
    key.Close();
}
 

愚蠢的,但它的方式。

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.

解决方案

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.

这篇关于燮preSS有关:在web浏览器的WinForms打印输出空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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