RSS

removing header and footer while printing

31 May

First Solution

For IE & FireFox

<a href=”javascript:window.print();”>

<img title=”Print this page” src=”/images/print_icon.jpg”

border=”0″></a>

Second Solution

this is recommended code

<a href=”#”  onclick=”window.print()” onmouseup=”document.getElementById(‘header’).style.display=’None’;document.getElementById(‘footer’).style.display=’None'”> Print </a>

Third Solution

removing header and footer while printing the page through coding?

With C# Language

I have the code for making the header and footer to be removed dynamically while printing

public void IESetupFooter()

{

string strKey = “Software\\Microsoft\\Internet Explorer\\PageSetup”;

bool bolWritable = true;

string strName = “footer”;

object oValue = “”;

RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable);

Console.Write(strKey);

oKey.SetValue(strName, oValue);

oKey.Close();

}

public void IESetupHeader()

{

string strKey1 = “Software\\Microsoft\\Internet Explorer\\PageSetup”;

bool bolWritable1 = true;

string strName = “header”;

object oValue1 = “”;

RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey1, bolWritable1);

Console.Write(strKey1);

oKey.SetValue(strName, oValue1);

oKey.Close();

}

With Vb.Net

Public Sub IESetupFooter()
	Dim strKey As String = "Software\Microsoft\Internet Explorer\PageSetup"
	Dim bolWritable As Boolean = True
	Dim strName As String = "footer"
	Dim oValue As Object = ""
	Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable)
	Console.Write(strKey)
	oKey.SetValue(strName, oValue)
	oKey.Close()
End Sub
Public Sub IESetupHeader()
	Dim strKey1 As String = "Software\Microsoft\Internet Explorer\PageSetup"
	Dim bolWritable1 As Boolean = True
	Dim strName As String = "header"
	Dim oValue1 As Object = ""
	Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey1, bolWritable1)
	Console.Write(strKey1)
	oKey.SetValue(strName, oValue1)
	oKey.Close()
End Sub

Directly Remove from Browser

Internet Explorer 7

 

 

Firefox

 

 

 

Advertisements
 
7 Comments

Posted by on May 31, 2011 in ASP Dot Net C#, Java Script, Vb.Net

 

Tags: , , ,

7 responses to “removing header and footer while printing

  1. Programming Jobs

    June 2, 2011 at 6:29 am

    I enjoyed reading this post. I need to learn more on this subject. Thanks for writing this nice post.. Anyway, I’m gonna subscribe to your rss feed and I hope you post again soon.

     
    • humrahimcs

      June 4, 2011 at 9:13 pm

      Thanks Dear For complement……Visit my blog and i think when you write comment then blow show checkbox which give inform you next time or see on the top of page show the rss to add in google.

       
  2. Raul Sanchez

    December 8, 2011 at 8:57 pm

    Thanks, Very Helpfull

     
  3. Deângelo

    November 14, 2013 at 1:00 pm

    Helps a lot.
    Ty

     
  4. Murali

    October 6, 2014 at 10:07 am

    Hi I tried it using but couldn’t help, I need to hide header and footer of my print page, which I am doing by window.print.
    here how I am using it:

    Any help here

     
  5. shyam

    March 10, 2016 at 11:41 am

    public void IESetupFooter()
    {

    string strName = “footer”;

    object oValue = “”;

    //RegistryKey oKey = Registry.CurrentUser.OpenSubKey(strKey, bolWritable);
    RegistryKey registry = Registry.CurrentUser.OpenSubKey(“Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings”, true);

    registry.SetValue(strName, oValue);

    registry.Close();

    }

    public void IESetupHeader()
    {

    string strName = “header”;

    object oValue1 = “”;
    RegistryKey registry = Registry.CurrentUser.OpenSubKey(“Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings”, true);

    registry.SetValue(strName, oValue1);

    registry.Close();

    }

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: