0

I have a .net Forms Application with webbrowser control. I have a html file loaded in the control. I want to set Margins, Headers and Footers and orientation from the code itself for printing that document...

webbrowser1.ShowPageSetupDialog()
webbrowsre1.print()

Currently I set these manually by calling the pagesetupDialog . How do i set these all the required options from code ?

Thank you!

4

1 回答 1

1

我最后一次检查,webbrowser 控件的页眉和页脚实际上存储在注册表中。要更改它们,您可以简单地更新注册表值。当然,这会影响 IE,而不仅仅是 webbrowser 控件。

密钥在 Microsoft.Win32.Registry.CurrentUser 下:“Software\Microsoft\Internet Explorer\PageSetup”

您可能希望在更改之前缓存该值,以便在完成打印后将其更改回来。它并不优雅,如果有人有更优雅的解决方案,我很乐意前往,但似乎 webbrowser 控件并不真正支持我们想要的所有功能。

于 2011-08-06T03:01:11.123 回答