0

I'm using ITextRenderer to generate pdf in my application by loading a html file with internal styles. My HTML page is like this:

<html>
<head>
    <style type="text/css">.TFtable tr:nth-child(even) {background: #ffffff; border:none;}</style>
</head>
<body>
    <table class="TFtable" width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><th align="left" valign="middle" scope="col"> Customer </th> </tr>
    </table>
</body>
</html>
Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73
Jagadeesh
  • 87
  • 1
  • 13

1 Answers1

0

Interestingly, it's working fine for me. Please note that in the sample html code that you provided, you are setting background color as white. Also, you are adding only one row to the table. As, you are using 'tr:nth-child(even)' as a selector, the style will not be applied to the first row (which odd number). Try following code, which is slight modification to your sample code.

<html>
<head>
<style type="text/css">
.TFtable  tr:nth-child(even) {
  background: #eee;
  border: none;
}
</style>
</head>
<body>
  <table class="TFtable" width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th align="left" valign="middle" scope="col">Customer-odd</th>
    </tr>
    <tr>
      <th align="left" valign="middle" scope="col">Customer-even</th>
    </tr>
  </table>
</body>
</html>

In output pdf (and in html) you will see second row with gray background. I hope this is useful.

Sachin Doshi
  • 889
  • 7
  • 8