C# itextsharp:如果未设置行的底部边框,如何显示属性HeaderRows=1的表的底线?

C# itextsharp:如果未设置行的底部边框,如何显示属性HeaderRows=1的表的底线?,c#,.net,itextsharp,C#,.net,Itextsharp,我使用的是itextsharp的最新版本 我使用HeaderRows=1属性,这样如果有分页符,标题行将再次出现在下一页中 然后我们就有了边框样式的内容行,没有底线,如下所示: PdfPCell cell1 = null; cell1 = new PdfPCell(new Phrase(string.Format("{0}", c1), fn)); cell1.Border = Rectangle.RIGHT_BORDER | Rectangle.LEFT_BORDER; PdfPT

我使用的是itextsharp的最新版本

我使用HeaderRows=1属性,这样如果有分页符,标题行将再次出现在下一页中

然后我们就有了边框样式的内容行,没有底线,如下所示:

 PdfPCell cell1 = null;
 cell1 = new PdfPCell(new Phrase(string.Format("{0}", c1), fn));
 cell1.Border = Rectangle.RIGHT_BORDER | Rectangle.LEFT_BORDER;
  PdfPTable ItemTable = new PdfPTable(7);
    ItemTable.TableEvent = new LineaBottom();
当有分页符时,表的行底部不显示,这是不符合逻辑的。 即使内容行没有底部/顶部边框,PdfPTable本身也应该有边框(实际上代码中没有)


有什么想法吗?Thx.

我想我很幸运,这不容易找到

我正在寻找一些事件来定位页面的最后一行,我找到了它

你可以这样举例:

 PdfPCell cell1 = null;
 cell1 = new PdfPCell(new Phrase(string.Format("{0}", c1), fn));
 cell1.Border = Rectangle.RIGHT_BORDER | Rectangle.LEFT_BORDER;
  PdfPTable ItemTable = new PdfPTable(7);
    ItemTable.TableEvent = new LineaBottom();
课程如下:

 public class LineaBottom : IPdfPTableEvent
{


    #region IPdfPTableEvent Members

    void IPdfPTableEvent.TableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases)
    {
        int columns;
        Rectangle rect;
        int footer = widths.Length - table.FooterRows;
        int header = table.HeaderRows - table.FooterRows + 1;
        int ultima = footer - 1;
        if (ultima != -1)
        {
            columns = widths[ultima].Length - 1;
            rect = new Rectangle(widths[ultima][0], heights[ultima], widths[footer - 1][columns], heights[ultima + 1]);
            rect.BorderColor = BaseColor.BLACK;
            rect.BorderWidth = 1;
            rect.Border = Rectangle.TOP_BORDER;
            canvases[PdfPTable.BASECANVAS].Rectangle(rect);
        }
    }

    #endregion
}