How to fit the TableCell width to its content width?

1 posts, 0 answers
  1. Art
    Art avatar
    23 posts
    Member since:
    Apr 2015

    Posted 13 Oct 2015 Link to this post

    I'm trying to create the label cell (two column layout). But it occupies 50% of the table width.

    var table = new Table
    {
        CellPadding = new Padding(0),
        PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100),
    };

    Row:

    var bodyRow = new TableRow();
     
    if (columnCount == 2)
    {
        bodyRow.Cells.Add(new TableCell
        {
            Blocks =
            {
                new Paragraph
                {
                    Inlines =
                    {
                        new Span
                        {
                            FontSize = Settings.LeftLabel.FontSize,
                            FontWeight = FontWeights.Bold,
     
                            Text = Settings.LeftLabel.Text
                        }
                    }
                }
            },
     
            PreferredWidth = new TableWidthUnit(TableWidthUnitType.Auto)
        });
    }
     

    A good solution would be to reduce the size of the cell without word breaking.

    The table is not attached to the document, and does not know its real size while builds.​

Back to Top