net*_*tos 6 .net c# 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;
Run Code Online (Sandbox Code Playgroud)
如果存在分页,则不会显示表格的行底部,这不符合逻辑.即使内容行没有底部/顶部边框,PdfPTable本身也应该有边框(事实上它在代码中没有).
有任何想法吗?谢谢.
我想我很幸运,这不容易找到.
我正在寻找一些事件来本地化页面的最后一行,我找到了它.
你这样实例:
PdfPTable ItemTable = new PdfPTable(7);
ItemTable.TableEvent = new LineaBottom();
Run Code Online (Sandbox Code Playgroud)
该课程如下:
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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3521 次 |
| 最近记录: |