Solved

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

Posted on 2008-10-22
5
1,091 Views
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
me.webbrowser1.navigate("http://www.google.com")

me.webbrowser1.showprintdialog()

Open in new window

0
Comment
Question by:Crazy_Penguins
  • 3
5 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22778820
is this link of any help
http://support.microsoft.com/kb/313723
0
 
LVL 19

Accepted Solution

by:
Stephen Manderson earned 500 total points
ID: 22778923
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
 

Author Comment

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

0
 

Author Comment

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

Open in new window

0
 

Author Comment

by:Crazy_Penguins
ID: 22780968
Works great, thanks.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now