Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Webbrowser control print preview not working for background color

Webbrowser control print preview not working for background color

Scheduled Pinned Locked Moved C#
csharphtmlarchitecturequestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shukra
    wrote on last edited by
    #1

    Hi, In c# i generated HTML report (colored). I am using Webbrowser control. I need to print it. But unfortunately i cannot print the color (background color). why? A sample report is as below.

    <html>
    <head>
    <title>Test</title>

    </head>

    <body align=center >

    <table align=center border=0 width=1000>

    <tr>

    <td align=center class=title style='border:2px solid red;'>110P-1 PRODUCTION SCHEDULE</td>
    

    </tr>

    </table>

    <table align=center border=1 width=1000 cellspacing=0 cellpadding=0>

    <tr>

    <td colspan=3 align=right>&nbsp; <b>TOTALS:</b> </td>
    
    <td align=center ><b>22160.00</b></td>
    
    <td align=center ><b>15828.57</b></td>
    
    <td align=center ><b>18000.09</b></td>
    
    <td align=center><b>2971.36</b></td>
    
    <td align=center><b>33</b></td>
    
    <td >&nbsp;</td>
    

    </tr>

    <tr>

    <td align=center ><b>DEL.DATE</b></td>
    
    <td align=center ><b>COLOUR</b></td>
    
    <td align=center><b>ADDRESS</b></td>
    
    <td align=center ><b>L/M</b></td>
    
    <td align=center ><b>HOURS@1.4m</b></td>
    
    <td align=center ><b>COMPLETE</b></td>
    
    <td align=center ><b>REMAIN HOURS</b></td>
    
    <td align=center ><b>PACKS</b></td>
    
    <td align=center ><b>STATUS</b></td>
    

    </td>

    <tr><td align=center > 20/11/2009</td>
    <td align=center style='background-color:#FF8C00;'> </td>
    <td align=center > Hamilton Iland</td>
    <td align=center > 20310.00</td>
    <td align=center > 14507.14</td>
    <td align=center> 18000.09</td>
    <td align=center > 1649.94</td>
    <td align=center > 33</td>
    <td align=center > </td></tr>

    <tr><td align=center > 16/11/2009</td>
    <td align=center style='background-color:#14A0E6;'> </td>
    <td align=center > Bankstown</td>
    <td align=center > 1250.00</td>
    <td align=center > 892.86</td>
    <

    D RaviBeeR 2 Replies Last reply
    0
    • S Shukra

      Hi, In c# i generated HTML report (colored). I am using Webbrowser control. I need to print it. But unfortunately i cannot print the color (background color). why? A sample report is as below.

      <html>
      <head>
      <title>Test</title>

      </head>

      <body align=center >

      <table align=center border=0 width=1000>

      <tr>

      <td align=center class=title style='border:2px solid red;'>110P-1 PRODUCTION SCHEDULE</td>
      

      </tr>

      </table>

      <table align=center border=1 width=1000 cellspacing=0 cellpadding=0>

      <tr>

      <td colspan=3 align=right>&nbsp; <b>TOTALS:</b> </td>
      
      <td align=center ><b>22160.00</b></td>
      
      <td align=center ><b>15828.57</b></td>
      
      <td align=center ><b>18000.09</b></td>
      
      <td align=center><b>2971.36</b></td>
      
      <td align=center><b>33</b></td>
      
      <td >&nbsp;</td>
      

      </tr>

      <tr>

      <td align=center ><b>DEL.DATE</b></td>
      
      <td align=center ><b>COLOUR</b></td>
      
      <td align=center><b>ADDRESS</b></td>
      
      <td align=center ><b>L/M</b></td>
      
      <td align=center ><b>HOURS@1.4m</b></td>
      
      <td align=center ><b>COMPLETE</b></td>
      
      <td align=center ><b>REMAIN HOURS</b></td>
      
      <td align=center ><b>PACKS</b></td>
      
      <td align=center ><b>STATUS</b></td>
      

      </td>

      <tr><td align=center > 20/11/2009</td>
      <td align=center style='background-color:#FF8C00;'> </td>
      <td align=center > Hamilton Iland</td>
      <td align=center > 20310.00</td>
      <td align=center > 14507.14</td>
      <td align=center> 18000.09</td>
      <td align=center > 1649.94</td>
      <td align=center > 33</td>
      <td align=center > </td></tr>

      <tr><td align=center > 16/11/2009</td>
      <td align=center style='background-color:#14A0E6;'> </td>
      <td align=center > Bankstown</td>
      <td align=center > 1250.00</td>
      <td align=center > 892.86</td>
      <

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Because it follows the settings for Internet Explorer, which, by default, doesn't print the background at all.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      1 Reply Last reply
      0
      • S Shukra

        Hi, In c# i generated HTML report (colored). I am using Webbrowser control. I need to print it. But unfortunately i cannot print the color (background color). why? A sample report is as below.

        <html>
        <head>
        <title>Test</title>

        </head>

        <body align=center >

        <table align=center border=0 width=1000>

        <tr>

        <td align=center class=title style='border:2px solid red;'>110P-1 PRODUCTION SCHEDULE</td>
        

        </tr>

        </table>

        <table align=center border=1 width=1000 cellspacing=0 cellpadding=0>

        <tr>

        <td colspan=3 align=right>&nbsp; <b>TOTALS:</b> </td>
        
        <td align=center ><b>22160.00</b></td>
        
        <td align=center ><b>15828.57</b></td>
        
        <td align=center ><b>18000.09</b></td>
        
        <td align=center><b>2971.36</b></td>
        
        <td align=center><b>33</b></td>
        
        <td >&nbsp;</td>
        

        </tr>

        <tr>

        <td align=center ><b>DEL.DATE</b></td>
        
        <td align=center ><b>COLOUR</b></td>
        
        <td align=center><b>ADDRESS</b></td>
        
        <td align=center ><b>L/M</b></td>
        
        <td align=center ><b>HOURS@1.4m</b></td>
        
        <td align=center ><b>COMPLETE</b></td>
        
        <td align=center ><b>REMAIN HOURS</b></td>
        
        <td align=center ><b>PACKS</b></td>
        
        <td align=center ><b>STATUS</b></td>
        

        </td>

        <tr><td align=center > 20/11/2009</td>
        <td align=center style='background-color:#FF8C00;'> </td>
        <td align=center > Hamilton Iland</td>
        <td align=center > 20310.00</td>
        <td align=center > 14507.14</td>
        <td align=center> 18000.09</td>
        <td align=center > 1649.94</td>
        <td align=center > 33</td>
        <td align=center > </td></tr>

        <tr><td align=center > 16/11/2009</td>
        <td align=center style='background-color:#14A0E6;'> </td>
        <td align=center > Bankstown</td>
        <td align=center > 1250.00</td>
        <td align=center > 892.86</td>
        <

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        To follow up on Dave's response, you don't need to use a WebBrowserControl to print your document.  Simply save the HTML to a temporary file and do the .NET equivalent of ShellExecute (..., "print", ...) to print it.  The .NET equivalent is Process.Start(). /ravi

        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

        S 1 Reply Last reply
        0
        • RaviBeeR RaviBee

          To follow up on Dave's response, you don't need to use a WebBrowserControl to print your document.  Simply save the HTML to a temporary file and do the .NET equivalent of ShellExecute (..., "print", ...) to print it.  The .NET equivalent is Process.Start(). /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          S Offline
          S Offline
          Shukra
          wrote on last edited by
          #4

          Thanks Ravi, Will you pls tell me if. Is there any way to change IE printer settings from c# code? 1.I want to dynamically set page orientation to "Landscape" or "Portrait" 2.I want to remove the header or footer. (I can change the values from registry, but don't know how to disable it?) Thanks again, Shukra

          RaviBeeR 1 Reply Last reply
          0
          • S Shukra

            Thanks Ravi, Will you pls tell me if. Is there any way to change IE printer settings from c# code? 1.I want to dynamically set page orientation to "Landscape" or "Portrait" 2.I want to remove the header or footer. (I can change the values from registry, but don't know how to disable it?) Thanks again, Shukra

            RaviBeeR Offline
            RaviBeeR Offline
            RaviBee
            wrote on last edited by
            #5

            Clickety[^] /ravi

            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups