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

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
me.webbrowser1.navigate("http://www.google.com")
me.webbrowser1.showprintdialog()

Open in new window

Crazy_PenguinsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anurag ThakurTechnical ManagerCommented:
is this link of any help
http://support.microsoft.com/kb/313723
0
Stephen MandersonSoftware EngineerCommented:
Hi there

Heres how I do it.

Regards
Steve
        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"))
 
            Me.WebBrowser1.ShowPrintDialog()
 
            '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
 
        RegKey.Close()

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Crazy_PenguinsAuthor Commented:
Type 'RegistryKey' is not defined. - any thoughts?

0
Crazy_PenguinsAuthor Commented:
Found:
Dim RegKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(RegKeyPath, KeyWritable)

Open in new window

0
Crazy_PenguinsAuthor Commented:
Works great, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.