We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Shape does not expand table

Hi Brave and patient supporters!

Expected that inserted shapes expand tables. But somehow code:

[Test]
public void Shape()
{
    var doc = new Document();
    var builder = new DocumentBuilder(doc);

    var table = builder.StartTable();

    builder.InsertCell();
    table.PreferredWidth = PreferredWidth.FromPercent(0);

    builder.Writeln("Text 1");
    builder.Write("Text 2");

    builder.InsertCell();

    var arrow = new Shape(doc.Document, ShapeType.Triangle)
    {
        Filled = true,
        Width = 10,
        Height = 10,
        Rotation = 180,
        StrokeColor = Color.Green,
        FillColor = Color.Green
    };

    builder.InsertNode(arrow);

    builder.InsertCell();
    builder.Write("Text 3");

    builder.InsertCell();

    arrow = new Shape(doc.Document, ShapeType.Triangle)
    {
        Filled = true,
        Width = 10,
        Height = 10,
        Rotation = 180,
        StrokeColor = Color.Green,
        FillColor = Color.Green
    };

    builder.InsertNode(arrow);

    builder.EndRow();
    builder.EndTable();

    doc.Save(@"C:\\Shape.docx");
}

Comes with different result. It proves that shape size is ignored while creating table. How I create table cell taking shape size in custody? Otherwise table expands if cell text grows. Logically should react to shape in a same way as it is located in the cell. Please some advice here.

Hi Philo,

Thanks for your inquiry. I think, you should make Shape to be inline with text in Cell. Please see the following property and code change:
https://reference.aspose.com/words/net/aspose.words.drawing/shapebase/wraptype/

var arrow = new Shape(doc.Document, ShapeType.Triangle)
{
    Filled = true,
    Width = 10,
    Height = 10,
    Rotation = 180,
    StrokeColor = Color.Green,
    FillColor = Color.Green,
    WrapType= WrapType.Inline
};

I hope, this helps.

Best regards,

Thanks, works like charm and as expected.
Have a nice and sunny day!