Question

I want to export one html page to pdf with iTextSharp. I have 2 tables and I want to put border for first table but not for another

//my first tabe
strHTMLContent.Append("<table width='100%'>");
strHTMLContent.Append("<tr>");
strHTMLContent.Append("<td>" text "</td>");
strHTMLContent.Append("<td>" text "</td>");
strHTMLContent.Append("<td>");

//the 2nd table that I don't want to have border
strHTMLContent.Append("<table>");
strHTMLContent.Append("<tr><td>" row1 " </td></tr> ");
strHTMLContent.Append("<tr><td> " row2" </td></tr> ");
strHTMLContent.Append("<tr><td>  " row3 " </td></tr> ");
strHTMLContent.Append("</table >");
strHTMLContent.Append("</td>");
strHTMLContent.Append("</tr>");
strHTMLContent.Append("</table >");

//I use StyleSheet for set border size
var st = new StyleSheet();
st.LoadTagStyle("table", "border", "1");
Was it helpful?

Solution

Maybe a bit too late but yet - you cannot change border sizes, only yes or no. Too sad, but that's how it is with itextsharp. Regarding your problem, you can easily set the border directly on the html tags and remove the LoadTagStyle call:

//my first tabe
strHTMLContent.Append("<table width='100%' border='1'>");

//the 2nd table that I don't want to have border
strHTMLContent.Append("<table border='0'>");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top