[英]iText java - Split table vertically and horizontally and add header row
[英]Itext : Split row issue
我遇到Itext问题,在两页之间剪切了一行。 我的代码是这样的:
PdfPTable Master = new PdfPTable(1);
Master.setHeaderRows(1);
PdfPTable Header = new PdfPTable(1);//create header table
//fill header
PdfPCell HeaderCell = new PdfPCell();
HeaderCell.addElement(Header);
Master.addCell(HeaderCell);//add header in master
foreach result in query
{
float[] colsWidth = { 4f, 9f, 5f, 8f };
PdfPTable Content = new PdfPTable(colsWidth);//create content table
//fill content
content.keepRowsTogether(0);
PdfPCell ContentCell = new PdfPCell();
ContentCell.addElement(Content);
Master.addCell(ContentCell);//add header in master
}
document.add(Master);
但是在PDF文档中,某些“内容”表分为两页(因此,有些“主表”行)。 我尝试添加:
Master.keepRowsTogether(0);
Master.setSplitLate(false);
没有任何效果。
我也尝试过:
Master.setSplitRows(false);
但这会使剪切的行完全消失。 有人知道如何禁用主表中的行拆分吗?
在要拆分的单元格中也启用环绕
ContentCell .setNoWrap(false);
所以
foreach result in query
{
float[] colsWidth = { 4f, 9f, 5f, 8f };
PdfPTable Content = new PdfPTable(colsWidth);//create content table
//fill content
content.keepRowsTogether(0);
PdfPCell ContentCell = new PdfPCell();
ContentCell .setNoWrap(false);
ContentCell.addElement(Content);
Master.addCell(ContentCell);//add header in master
}
并且不要忘记Master.setSplitLate(false);
这适用于itextsharp 5
TableName.SplitLate = False
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.