【问题标题】:Setting width of table inside another table is not reflecting in created pdf在另一个表中设置表的宽度未反映在创建的 pdf 中
【发布时间】:2015-09-24 11:28:42
【问题描述】:

下面是我正在使用的代码。我想要一个宽度为 40 的表,并且在该表内,还有另一个宽度为 25 的表。无论我给内表赋予什么值,它似乎都有一个固定的宽度。它尝试了不同的选项,例如“LockedWidth”,但这会使表格变得非常小。可以请任何人帮忙。

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);

【问题讨论】:

    标签: c# pdf-generation itextsharp


    【解决方案1】:

    我现在无法尝试,但我认为这应该会有所帮助:

    innerTable.WidthPercentage = 62.5f;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-10
      • 2018-05-05
      • 1970-01-01
      • 1970-01-01
      • 2012-03-01
      • 1970-01-01
      • 2014-08-08
      • 2016-09-05
      相关资源
      最近更新 更多