在另一个 table 中设置 table 的宽度未反映在创建的 pdf 中
Setting width of table inside another table is not reflecting in created pdf
下面是我正在使用的代码。我想要一个宽度为 40 的 table,在那个 table 里面,还有一个宽度为 25 的 table。无论我给内部 table 赋予什么值,它似乎都有一个固定宽度。它尝试了不同的选项,例如 'LockedWidth',但这使得 table 非常小。可以请任何人帮忙吗。
PdfPTable outerTable = new PdfPTable(1) { HorizontalAlignment = 0 };
outerTable.TotalWidth = 40;
PdfPCell outerTableColumn = new PdfPCell()
{
FixedHeight = 20,
BackgroundColor = new BaseColor(217, 83, 79)
};
PdfPTable innerTable = new PdfPTable(1) { HorizontalAlignment = 0 };
innerTable.TotalWidth = 28;
PdfPCell innerTableColumn = new PdfPCell()
{
FixedHeight = 15,
BackgroundColor = new BaseColor(92, 184, 92)
};
innerTable.AddCell(innerTableColumn);
outerTableColumn.AddElement(innerTable);
outerTable.AddCell(outerTableColumn);
我现在无法尝试,但我认为这应该有所帮助:
innerTable.WidthPercentage = 62.5f;
下面是我正在使用的代码。我想要一个宽度为 40 的 table,在那个 table 里面,还有一个宽度为 25 的 table。无论我给内部 table 赋予什么值,它似乎都有一个固定宽度。它尝试了不同的选项,例如 'LockedWidth',但这使得 table 非常小。可以请任何人帮忙吗。
PdfPTable outerTable = new PdfPTable(1) { HorizontalAlignment = 0 };
outerTable.TotalWidth = 40;
PdfPCell outerTableColumn = new PdfPCell()
{
FixedHeight = 20,
BackgroundColor = new BaseColor(217, 83, 79)
};
PdfPTable innerTable = new PdfPTable(1) { HorizontalAlignment = 0 };
innerTable.TotalWidth = 28;
PdfPCell innerTableColumn = new PdfPCell()
{
FixedHeight = 15,
BackgroundColor = new BaseColor(92, 184, 92)
};
innerTable.AddCell(innerTableColumn);
outerTableColumn.AddElement(innerTable);
outerTable.AddCell(outerTableColumn);
我现在无法尝试,但我认为这应该有所帮助:
innerTable.WidthPercentage = 62.5f;