问题描述
我向标题单元格添加了一个大文本,表格的另一个单元格不会改变它们的高度 image。
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));
tblChcklist.SetKeepTogether(true).SetFontSize(10).SetFixedLayout();
tblChcklist.AddHeaderCell(handler.getCell(2,1,"No.",TextAlignment.CENTER).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE));
tblChcklist.AddHeaderCell(handler.getCell(2,$"Seccion {dtPreguntas.Rows[0]["nombreSeccion"] }",TextAlignment.LEFT).SetBold());
tblChcklist.AddHeaderCell(handler.getCell(0,"Si",TextAlignment.CENTER));
tblChcklist.AddHeaderCell(handler.getCell(0,"No","No Aplica",TextAlignment.CENTER));
这里是 handle.getCell 方法
public Cell getCell(int rowspan,int colspan,String text,TextAlignment alignment)
{
Cell cell = new Cell(rowspan,colspan).Add(new Paragraph(text));
cell.AddStyle(new Style().SetBorderBottom(new SolidBorder(ColorConstants.BLACK,0)));
cell.AddStyle(new Style().SetBorderTop(new SolidBorder(ColorConstants.BLACK,0)));
cell.SetPadding(0);
cell.SetTextAlignment(alignment);
cell.SetKeepTogether(true);
return cell;
}