简体   繁体   English

使用带有表格边框的iTextSharp生成HTML到Pdf

[英]Generate HTML to Pdf using iTextSharp with table border

I want to add bottom and top border of table contents. 我想添加表格内容的底部和顶部边框。 I have use ItextSharp.dll. 我使用了ItextSharp.dll。 All style properties are working using following code But border properties are not working. 使用以下代码,所有样式属性都可以使用,但是边框属性不起作用。
-- I try this code but it is not working for border properties -我尝试使用此代码,但不适用于边框属性

styles.LoadTagStyle("tr", "border-bottom-color", "Yellow");
styles.LoadTagStyle("tr", "border-bottom-width", "2px");
styles.LoadStyle("topBorder", "border-top-width", "2px");
styles.LoadStyle("topBorder", "border-top-color", "#985623");

If itextSharp is not support that properties then give any other way but using HTMl 如果itextSharp不支持该属性,则可以使用HTMl进行其他选择

can you please try this 你可以试试这个吗

<table border="1">

hope it will work 希望它能工作

try with the following 尝试以下

for all cell of first row 对于第一行的所有单元格

 cell.Border =  PdfCell.TOP_BORDER

for all cell of last row 对于最后一行的所有单元格

cell.Border =  PdfCell.BOTTOM_BORDER

just do it for the every first row cell and every last row cell and u will get border at bottom and top of the table 只需对每个第一行单元格和每个最后一行单元格执行此操作,您将在表格的底部和顶部获得边框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM