How to remove Head/Foot sections from WebBrowser Print...

Posted on 2008-10-22
Last Modified: 2008-10-22
I am using a web browser to print from my VB.NET application, however whenever I print, it places the page name on the top, page x-of-y on the top, the URL, and Date on the bottom.  I don't want to print this and need to know how to remove this.  For a basic example, drop a web browser onto a form, and add the code below..

Thanks, Andrew

Open in new window

Question by:Crazy_Penguins
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22778820
is this link of any help
LVL 19

Accepted Solution

Stephen Manderson earned 500 total points
ID: 22778923
Hi there

Heres how I do it.

        Dim RegKeyPath As String = "Software\\Microsoft\\Internet Explorer\\PageSetup"
        Dim KeyWritable As Boolean = True
        Dim RegKey As RegistryKey = Registry.CurrentUser.OpenSubKey(RegKeyPath, KeyWritable)
        Dim TopMargin As String = "margin_top"
        Dim BottomMargin As String = "margin_bottom"
        Dim RightMargin As String = "margin_right"
        Dim LeftMargin As String = "margin_left"
        Dim Footer As String = "footer"
        Dim FooterValue As Object = ""
        Dim Header As String = "header"
        Dim HeaderValue As Object = ""
        If RegKey IsNot Nothing Then
            'Can be used to store the default values
            'Dim TmpTopMargin As String = RegKey.GetValue(TopMargin)
            'Dim TmpBottomMargin As String = RegKey.GetValue(BottomMargin)
            'Dim TmpRightMargin As String = RegKey.GetValue(RightMargin)
            'Dim TmpLeftMargin As String = RegKey.GetValue(LeftMargin)
            'Dim TmpFooter As String = RegKey.GetValue(Footer)
            'Dim TmpFooterValue As Object = RegKey.GetValue(FooterValue)
            'Dim TmpHeader As String = RegKey.GetValue(Header)
            'Dim TmpHeaderValue As Object = RegKey.GetValue(HeaderValue)
            RegKey.SetValue(Footer, FooterValue)
            RegKey.SetValue(Header, HeaderValue)
            RegKey.SetValue(TopMargin, CDbl("0.25"))
            RegKey.SetValue(BottomMargin, CDbl("0.25"))
            RegKey.SetValue(RightMargin, CDbl("0.25"))
            RegKey.SetValue(LeftMargin, CDbl("0.25"))
            'Can be used to set values back
            'RegKey.SetValue(Footer, TmpFooterValue)
            'RegKey.SetValue(Header, TmpHeaderValue)
            'RegKey.SetValue(TopMargin, CDbl(TmpTopMargin))
            'RegKey.SetValue(BottomMargin, CDbl(TmpBottomMargin))
            'RegKey.SetValue(RightMargin, CDbl(TmpRightMargin))
            'RegKey.SetValue(LeftMargin, CDbl(TmpLeftMargin))
        End If

Open in new window


Author Comment

ID: 22780912
Type 'RegistryKey' is not defined. - any thoughts?


Author Comment

ID: 22780925
Dim RegKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RegKeyPath, KeyWritable)

Open in new window


Author Comment

ID: 22780968
Works great, thanks.

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question