问题描述
我尝试将我的表格和标题行设置为 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 (将#修改为@)