1

I am trying to print content of WebBrowser Control. When I save the content as .xps file , I see no color in the table when I right click the webbrowser control and click print. Does webbrowser control remove color formatting when printing? There has to be some explanation.

 WebBrowser1.DocumentText = "<table border='1' > <tr><td bgcolor='blue'>No Color</td></tr> </table>"

I am able to see color in the webbrowser control but it removes color when saving it as xps?

SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
  • `WebBrowser` control uses the Internet Explorer version currently installed on the computer. – spongebob Nov 01 '14 at 09:11
  • I have IE8 and BrowserCotnrol renders html just fine. It is only when I print this BrowserControl that it loses its color formatting. – SamuraiJack Nov 01 '14 at 09:19

1 Answers1

2

It's a browser setting.

Your browser (Internet Explorer) is not set up to print background colors and images. I don't think you can easily change that programmaticaly but it might be possible. See this stackoverflow question for better explanation of the issue and possible solutions.

I ran in to the same issue some time ago, where the printed page just had to look excactly like the webpage, and ended up spending a lot of time creating a PDF file to send the user instead.

I think it might be possible to find a registry key to set for Internet Explorer so the setting is automaticly set.

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main The value is "Print_Background" source

Community
  • 1
  • 1
Kaspar Kjeldsen
  • 936
  • 1
  • 13
  • 30
  • 2
    Changing this key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\Print_Background actually works well for me, you can save the current state with `string old_bg = key.GetValue("Print_Background").ToString();` and set the value to 'yes' before reseting original value – TmZn Feb 05 '20 at 16:49