Rss Feed Like Us on facebook Google Plus

June 27, 2013

change internet explorer page setup programmatically with C#

Change printer setting of internet explorer with C#,basically you can change it bu updating
registry key.

Users can easily change Internet Explorer printer settings for the page margins, the header, and the footer through the Internet Explorer user interface. However, Internet Explorer and the Web Browser control do not include methods to change these settings programmatically.

The following steps outline how Microsoft Internet Explorer accesses the printer settings:

  1. Internet Explorer tries to obtain the values from the following registry key:
    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
  2. If the key in step 1 does not exist, Internet Explorer tries to create this key by copying the values from the following key:
    HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\PageSetup
  3. If the key in step 2 does not exist, default values are provided.
Checkout the below program..

using Microsoft.Win32;
namespace iesttings
    Class ie
        public void ChangeIEPageSetupSetting()
            string strKey = "Software\\Microsoft\\Internet Explorer\\PageSetup";
            bool bolWritable = true;
            string strName = "header";
            object oValue = "";
            string strName1 = "footer";
            object oValue1 = "";
            string strName2 = "margin_top";
            object oValue2 = "0.75";
            string strName3 = "margin_right";
            object oValue3 = "0.75";
            string strName4 = "margin_bottom";
            object oValue4 = "0.75";
            string strName5 = "margin_left";
            object oValue5 = "0.75";
            RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable);
            oKey.SetValue(strName, oValue);
            Console.WriteLine("0 updated");
            oKey.SetValue(strName1, oValue1);
            Console.WriteLine("1 updated");
            oKey.SetValue(strName2, oValue2);
            Console.WriteLine("2 updated");
            oKey.SetValue(strName3, oValue3);
            Console.WriteLine("3 updated");
            oKey.SetValue(strName4, oValue4);
            Console.WriteLine("4 updated");
            oKey.SetValue(strName5, oValue5);
            Console.WriteLine("5 updated");
    class Program
        static void Main(string[] args)
           ie obj = new ie();

Note : - Your Web Application should have rights to change the registry settings.

© 2011-2016 Techimpulsion All Rights Reserved.

The content is copyrighted to Tech Impulsion and may not be reproduced on other websites.