我使用的是最新版本的 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 本身也应该有边框(实际上代码中没有)。
有什么想法吗?谢谢。
最佳答案
我觉得我很幸运,这不容易找到。
我正在寻找一些事件来本地化页面的最后一行,我找到了它。
你像这样实例化它:
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
}
关于c# - itextsharp:如果未设置行的底部边框,如何显示属性为 HeaderRows=1 的表格的底线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6437905/