How to print css applied background images with the winforms webbrowser control

Posted by Geir-Tore Lindsve on Stack Overflow See other posts from Stack Overflow or by Geir-Tore Lindsve
Published on 2008-09-07T09:51:09Z Indexed on 2010/03/19 6:41 UTC
Read the original article Hit count: 529

Filed under:
|
|
|
|

I am using the webbrowser control in winforms and discovered now that background images which I apply with css are not included in the printouts.

Is there a way to make the webbrowser print the background of the displayed document too?

Edit: Since I wanted to do this programatically, I opted for this solution:

using Microsoft.Win32;

...

RegistryKey regKey = Registry.CurrentUser
                    .OpenSubKey("Software")
                    .OpenSubKey("Microsoft")
                    .OpenSubKey("Internet Explorer")
                    .OpenSubKey("Main");

//Get the current setting so that we can revert it after printjob
var defaultValue = regKey.GetValue("Print_Background");
regKey.SetValue("Print_Background", "yes");

//Do the printing

//Revert the registry key to the original value
regKey.SetValue("Print_Background", defaultValue);

Another way to handle this might be to just read the value, and notify the user to adjust this himself before printing. I have to agree that tweaking with the registry like this is not a good practice, so I am open for any suggestions.

Thanks for all your feedback

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms