如何解决iText 表 SetKeepTogether 重复标题行
我尝试将我的表格和标题行设置为 SetKeepTogether(true),但发生了这种情况 image,我尝试设置所有单元格 SetKeepTogether (true) 但它仍然使行中的分页符。 SetKeepWithNext 在这里有帮助吗?
clsPDfheader handler = new clsPDfheader(dtTestHeader(),document);
pdfDocument.AddEventHandler(PdfDocumentEvent.END_PAGE,handler);
document.SetMargins(30 + handler.GetTableHeight(),36,36);
Table tblChcklist = new Table(UnitValue.CreatePercentArray(new float[] { 4,35,20,20 })).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER).UseAllAvailableWidth().SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA,PdfEncodings.WINANSI,false)).SetFontSize(10);
foreach (DaTarow drS in dtS.copyToDataTable().Rows)
{
tblChcklist = new Table(UnitValue.CreatePercentArray(new float[] { 4,false)).SetKeepTogether(true);
tblChcklist.AddHeaderCell(new Cell(2,1).Add(new Paragraph($"No.").SetTextAlignment(TextAlignment.CENTER).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE)));
tblChcklist.AddHeaderCell(new Cell(2,1).Add(new Paragraph($"Seccion {drS["nombreSeccion"]}").SetBold()));
tblChcklist.AddHeaderCell(new Cell().Add(new Paragraph("Si").SetTextAlignment(TextAlignment.CENTER)));
tblChcklist.AddHeaderCell(new Cell().Add(new Paragraph("No").SetTextAlignment(TextAlignment.CENTER)));
tblChcklist.AddHeaderCell(new Cell().Add(new Paragraph("No Aplica").SetTextAlignment(TextAlignment.CENTER)));
var dtP = business.getPreguntasRevision().AsEnumerable().Where(r => r.Field<int>("idCatTipoChecklist") == idChecklist && r.Field<int>("idCatCheckListSeccion") == (int)drS["idCatCheckListSeccion"]);
if (dtP.Any())
{
int count = 1;
foreach (DaTarow drP in dtP.copyToDataTable().Rows)
{
tblChcklist.AddCell(new Cell(2,1).Add(handler.getCell($"{count}",TextAlignment.CENTER)));
tblChcklist.AddCell($"{drP["Pregunta"].ToString().Trim()}");
//3-4
//Si
tblChcklist.AddCell(handler.getCell($"\u0037",TextAlignment.CENTER).SetFont(PdfFontFactory.CreateFont(StandardFonts.ZAPFDINGBATS)));
//No
tblChcklist.AddCell(handler.getCell($"\u0037",TextAlignment.CENTER).SetFont(PdfFontFactory.CreateFont(StandardFonts.ZAPFDINGBATS)));
//NA
tblChcklist.AddCell(handler.getCell($"\u0037",TextAlignment.CENTER).SetFont(PdfFontFactory.CreateFont(StandardFonts.ZAPFDINGBATS)));
tblChcklist.AddCell(new Cell(1,5).Add(new Paragraph($"Comentario: ")));
count++;
}
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph()));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"Responsable").SetBold()));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"Firma").SetBold()));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"Fecha Compromiso").SetBold()));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"Fecha Terminación").SetBold()));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"Plantilla Cims - Checklist")));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph(String.Empty)));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"{DateTime.Now}")));
tblChcklist.AddCell(new Cell(0,0).Add(new Paragraph($"{DateTime.Now}")));
}
document.Add(tblChcklist.SetMarginBottom(10));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。