Re: WebBrowser Control Print and Preview Headers and Footers
- From: Mufaka <mufaka@xxxxxxxxxx>
- Date: Wed, 13 Feb 2008 22:23:12 -0800
** repost without attachment **
The header and footer are stored in the registry and are used for all instances.
http://support.microsoft.com/kb/313723
So, you can read those values before printing and store them in a variable. Then set them to empty before the print happens. After printing, reset the values to what they were.
To access the events for printing, you will need to get a reference to the underlying COM object SHDocVw.WebBrowser. Include a reference to Microsoft Internet Controls for this.
You can then cast to SHDocVw.WebBrowser from the WebBrowser controls ActiveXObject property. That exposes two events, PrintTemplateInstantiation and PrintTemplateTeardown. That is where you can handle setting the values of the header and footer.
http://www.mufaka.com/WebBrowserTest.zip contains a working example.
Bruce wrote:
I am using the .Net 2.0 WebBrowser control in a C# WinForms application to display and print custom HTML reports..
Is there a way to turn off the IE Page Setup headers and footers using C# before using the WebBrowser control's ShowPrintPreviewDialog() or ShowPrintDialog() methods so that the report formatting isn't thrown off by the Print Setup header and footer settings?
I would just like to turn them off, do my preview and print, then restore them to their previous values after the print or preview is finished.
I know users can go in an empty these values in the Page Setup dialog, but I would like to be able to do this without user interaction, and without changing the user's default page settings.
Thanks,
Bruce
- Follow-Ups:
- References:
- Prev by Date: Re: OwnerDrawn Combobox - Varying Fonts
- Next by Date: Re: OwnerDrawn Combobox - Varying Fonts
- Previous by thread: WebBrowser Control Print and Preview Headers and Footers
- Next by thread: Re: WebBrowser Control Print and Preview Headers and Footers
- Index(es):
Relevant Pages
|