C# iTextSharp:为两个表设置不同的边框大小

C# iTextSharp:为两个表设置不同的边框大小,c#,html,itextsharp,export-to-pdf,C#,Html,Itextsharp,Export To Pdf,我想用iTextSharp将一个html页面导出为pdf。我有两张桌子,我想为第一张桌子加边框,但不为另一张桌子加边框 //my first tabe strHTMLContent.Append("<table width='100%'>"); strHTMLContent.Append("<tr>"); strHTMLContent.Append("<td>" text "</td>"); strHTMLContent.Append("<t

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

//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");
//我的第一个选项卡
strHTMLContent.追加(“”);
strHTMLContent.追加(“”);
strHTMLContent.Append(““text”);
strHTMLContent.Append(““text”);
strHTMLContent.追加(“”);
//我不想要的第二张桌子
strHTMLContent.追加(“”);
strHTMLContent.Append(““row1”);
strHTMLContent.Append(““row2”);
strHTMLContent.Append(““row3”);
strHTMLContent.追加(“”);
strHTMLContent.追加(“”);
strHTMLContent.追加(“”);
strHTMLContent.追加(“”);
//我使用样式表来设置边框大小
var st=新样式表();
st.LoadTagStyle(“表格”、“边框”、“1”);

可能有点晚了,但是-您无法更改边框大小,只能更改是或否。太遗憾了,但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'>");
//我的第一个选项卡
strHTMLContent.追加(“”);
//我不想要的第二张桌子
strHTMLContent.追加(“”);