0

I am using itextsharp to convert html table to pdf.

It working fine but the width property is not working in PDF. Means when you change fix the width of column of a table to 20% or 20px its not reflecting on PDF .

How to set the width of column in PDF?

My Code :

"<table border='1'>"
    + "<thead><tr>" 
        + "<th style='width:10%;'>ID</th>"
        + "<th style='width:70%;'>Testing Point</th>"
        + "<th style='width:20%;'>Notes</th>"
    + "</tr></thead></table>"

Above code is showing table with border but total width of PDF is divided into 3 part. Each cell taking same width.

How can i fix the width of a table so that it will take user defined column width.

Please Help

Thanks

user1926138
  • 1,464
  • 7
  • 34
  • 53
  • possible duplicate of [itextsharp does not care my html styles](http://stackoverflow.com/questions/17918642/itextsharp-does-not-care-my-html-styles) – Adriano Repetti Jan 21 '14 at 11:13

1 Answers1

2

you must set td width in percentage for td in each row, not just in header row.

<table width="75%">
  <tr>
    <th scope="col" width="10%">&nbsp;</th>    <th scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td width="10%">&nbsp;</td>    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="10%">&nbsp;</td>    <td>&nbsp;</td>
  </tr>
</table>
swapnil shahane
  • 243
  • 1
  • 4
  • 13
  • Does not work on older versions of ITextSharp. So be sure that you are using the latest version! – Ozkan Sep 28 '18 at 07:36