webbrowser control page setup options from code

3.4k Views Asked by At

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!

1

There are 1 best solutions below

0
On BEST ANSWER

The last I checked, headers and footers for the webbrowser control are actually stored in the registry. To change them, you can simply update the registry values. Of course, this will affect IE, not just the webbrowser control.

The key is under Microsoft.Win32.Registry.CurrentUser here: "Software\Microsoft\Internet Explorer\PageSetup"

You might want to cache the value before you change it so you can change it back when you're done printing. It's not elegant and I'd love to head if anyone has a more elegant solution but it seems the webbrowser control doesn't really support all the features we would like it to.