webbrowser printing

前端 未结 1 954
北海茫月
北海茫月 2021-01-06 10:24

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

相关标签:
1条回答
  • 2021-01-06 11:08

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

    0 讨论(0)
提交回复
热议问题