Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webbrowser printing

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!!!

like image 808
Arsen Mkrtchyan Avatar asked Dec 06 '22 05:12

Arsen Mkrtchyan


1 Answers

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...

like image 94
Paolo Tedesco Avatar answered Dec 11 '22 08:12

Paolo Tedesco