views:

397

answers:

1

Hi
I am using C# WPF webbrowser control to show html file in my local machine, I added a print feature to my application by executing print command of webbrowser control, but default behavior of Internet Explorer is to print file url in the bottom of the screen , can I turn header and footer printing for my control? Have WebBrowser control ability to print preview? Sometimes printed page is cut, can someone help to understand what is the problem.
Thanks a lot!!!

+1  A: 

I did it once (sorry, I don't have the application code now), and I did it playing with the register: check this MS article.

I advice you to store somewhere the current values of the keys and restore them after you're done printing.

EDIT

string keyName = @"Software\Microsoft\Internet Explorer\PageSetup";
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true)) {
    if (key != null) {
          string old_footer = key.GetValue("footer");
          string old_header = key.GetValue("header");
          key.SetValue("footer", "");
          key.SetValue("header", "");
          Print();
          key.SetValue("footer", old_footer);
          key.SetValue("header", old_header);
    }
}

About pages being cut

I'm not sure if I understood correctly what the problem is... in the application I was talking about before, I had the problem of tables being cut in half, so I played with CSS break after property (see also break before) to force page breaks, specifying special styles for the printer media. Hope this helps...

Paolo Tedesco
Thanks for response Orsogufo I will check it now
ArsenMkrt
I added source that change registry values, may be someone will need it, thanks a lot your post is helpful, but the page is cut in some printers yet, can you help me with this?
ArsenMkrt
I modified your edit to restore the previous values as I had suggested :)What's the problem with the page being cut, exactly?
Paolo Tedesco
ok, thanks for modification, I don't know why printed text is cut, half of top and bottom lines are not shown in the printed page, when I print to tiff file the lines are cut, when xps file the page is printed normally, Thanks for help
ArsenMkrt