/*
You cannot change IE print settings programatically by interacting with the Web Browser control. Instead, you need to change registrty settings. Note that these changes are permanent, and will affect all subsequent IE print jobs.
Information on Printer Settings in the Registry
This is how Microsoft Internet Explorer accesses the printing settings. For Page Margins, Microsoft Internet Explorer first tries to get the values from this registry key:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
If there is no such a key, Internet Explorer create this key by copying the values from the following:
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\PageSetup
If there is no such key, default values are provided. For the Header and Footer, the values are picked up from the following:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
If there is no such key, default values are provided. The defaults are 0.75 for margins,"&w&bPage &p of &P" for header and "&u&b&d" for footer. For the Internet Explorer default printer, default values are provided from:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\printer
The developer could alter the above registry entries for the printing settings accordingly. Please note that these values are system-wide and affect all instances of the WebBrowser control and Internet Explorer for the current user.
*/
public void SetWebBrowserFooter()
{
// You cannot change IE print settings programatically
// by interacting with the Web Browser control. Instead,
// you need to change registrty settings. Note that
// these changes are permanent, and will affect all
// subsequent IE print jobs.
// This changes values for the footer
string RegistryKeyPath = "Software\\Microsoft\\Internet Explorer\\PageSetup";
bool isWritable = true;
string KeyName = "footer";
object NewValue = "Test Footer";
Microsoft.Win32.RegistryKey theKey =
Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RegistryKeyPath, isWritable);
Console.Write (RegistryKeyPath);
theKey.SetValue(KeyName,NewValue);
theKey.Close();
}
|