【发布时间】:2015-01-13 15:49:52
【问题描述】:
我正在使用 WPF WebBrowser 控件编写应用程序。它的来源是数据库中 xml/xslt 源的结果。
在包含WebBrowser 的窗口中,有一个使用处理程序进行打印的按钮:
mshtml.IHTMLDocument2 doc = WBrowser.Document as mshtml.IHTMLDocument2;
doc.execCommand("Print", true, 0);
但在这种情况下,打印文档中没有背景。我已经研究过这个问题,它是 Internet Explorer 页面设置对话框中的属性问题 - 允许打印背景颜色和图像。
我已尝试通过此代码进行更改:
RegistryKey regKey = Registry.CurrentUser
.OpenSubKey("Software", true)
.OpenSubKey("Microsoft", true)
.OpenSubKey("Internet Explorer", true)
.OpenSubKey("PageSetup", true);
var defaultValue = regKey.GetValue("Print_Background");
regKey.SetValue("Print_Background", "yes");
但这是糟糕的代码。我不想为一个简单的 bool 参数更改注册表值。
所以,我的问题是:如何在不修改注册表的情况下通过代码隐藏以编程方式更改此参数?
谢谢!
【问题讨论】:
标签: c# xml wpf internet-explorer printing