1

我想用 iTextSharp 将一个 html 页面导出为 pdf。我有 2 张桌子,我想为第一张桌子设置边框,但不想为另一张桌子设置边框

//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");
4

1 回答 1

0

也许有点太晚了,但是 - 你不能改变边框大小,只有是或否。太可悲了,但这就是itextsharp的情况。关于您的问题,您可以轻松地直接在 html 标签上设置边框并删除 LoadTagStyle 调用:

//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'>");
于 2013-09-02T19:33:41.337 回答