网页浏览器打印 [英] webbrowser printing

查看:172
本文介绍了网页浏览器打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用C#WPF WebBrowser控件显示HTML文件在我的本地机器上,我添加了打印功能,以我的应用程序通过执行WebBrowser控件的打印命令,不过IE的默认行为是打印文件URL在屏幕的底部,我可以把页眉和页脚打印我的控制?要打印preVIEW WebBrowser控件的能力?有时候打印的页面被切断,有人可以帮助了解是什么问题。
非常感谢!

Hi
I am using C# WPF webbrowser control to show html file in my local machine, I added a print feature to my application by executing print command of webbrowser control, but default behavior of Internet Explorer is to print file url in the bottom of the screen , can I turn header and footer printing for my control? Have WebBrowser control ability to print preview? Sometimes printed page is cut, can someone help to understand what is the problem.
Thanks a lot!!!

推荐答案

我做到了一次(对不起,我没有应用code现在),而我做到了与寄存器玩:检查<一HREF =htt​​p://support.microsoft.com/kb/236777>这个MS文章。

I did it once (sorry, I don't have the application code now), and I did it playing with the register: check this MS article.

我建议你到某个地方存储键的当前值,并恢复他们,你就大功告成了打印后。

I advice you to store somewhere the current values of the keys and restore them after you're done printing.

修改

string keyName = @"Software\Microsoft\Internet Explorer\PageSetup";
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true)) {
    if (key != null) {
          string old_footer = key.GetValue("footer");
          string old_header = key.GetValue("header");
          key.SetValue("footer", "");
          key.SetValue("header", "");
          Print();
          key.SetValue("footer", old_footer);
          key.SetValue("header", old_header);
    }
}

关于被切断网页

我不知道如果我理解正确的问题是什么?在我面前谈论的应用程序,我不得不被削减了一半表的问题,所以我打的属性之后//www.w3schools.com/CSS/pr%5F​​print%5Fpageba.asp\">CSS突破(见的 前休息)来强制分页符,指定特殊样式打印机的介质。希望这有助于...

I'm not sure if I understood correctly what the problem is... in the application I was talking about before, I had the problem of tables being cut in half, so I played with CSS break after property (see also break before) to force page breaks, specifying special styles for the printer media. Hope this helps...

这篇关于网页浏览器打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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