gpt4 book ai didi

c# - 从 WebBrowser 控件打印时删除页眉和页脚

转载 作者:太空宇宙 更新时间:2023-11-03 10:46:30 28 4
gpt4 key购买 nike

我有一个使用 MySql 数据库的 C# 应用程序。我使用 HTML 构建了一份报告。

我用标签填充字符串属性,并将内容以新形式发送到 WebBrowser 控件。

报表显示正确,但是当我调用打印预览对话框时,

webBrowser1.ShowPrintPreviewDialog();

页眉和页脚出现在报告中的值:

  • 在页眉中:# of pages.
  • 在页脚中:日期和“about:blank”。

这是问题的截图:

enter image description here

如何删除页眉和页脚?

最佳答案

看起来您可能必须在打印前更改注册表设置,然后再将它们改回来:

如何使用 Visual C# .NET 以编程方式更改 Internet Explorer 和 WebBrowser 控件的打印机设置

https://support.microsoft.com/en-us/kb/313723

using Microsoft.Win32;
//...............................

public void IESetupFooter()
{

string strKey = "Software\\Microsoft\\Internet Explorer\\PageSetup";
bool bolWritable = true;
string strName = "footer";
object oValue = "Test Footer";
RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey,bolWritable);
Console.Write (strKey);
oKey.SetValue(strName,oValue);
oKey.Close();
}

enter image description here

关于c# - 从 WebBrowser 控件打印时删除页眉和页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31052656/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com