How to print background image and styles in WebBrowser control

前端 未结 1 2054
太阳男子
太阳男子 2021-01-25 16:39

I want to print the background-images through my web browser control:

body {
    background-image: url(\"image url\");
}

To do so, I\'m generat

相关标签:
1条回答
  • 2021-01-25 17:32

    There is a Print Background Colors and Images setting in Page Setup dialog which is shared between Web Browser Control and Internet Explorer.

    Page setup settings for Microsoft Internet Explorer are stored in the following registry key:

    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
    

    Print Background Colors and Images value is stored in Print_Background key which can be yes or no. You can change the setting using code, but just keep in mind, these values are system-wide settings and will affect all instances of the WebBrowser control and Internet Explorer for the current user:

    using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
        @"Software\Microsoft\Internet Explorer\PageSetup", true))
    {
        key.SetValue("Print_Background", "yes", Microsoft.Win32.RegistryValueKind.String);
    }
    

    Here is the test html that I used:

    <html>
      <head>
        <style>
         body { background-image: url("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"); } 
        </style>
      </head>
      <body>
      </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题