ShapeBaseIsLayoutInCell Property

Gets or sets a flag indicating whether the shape is displayed inside a table or outside of it.

Namespace:  Aspose.Words.Drawing
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public bool IsLayoutInCell { get; set; }

Property Value

Type: Boolean
Remarks

The default value is true.

Has effect only for top level shapes, the property WrapType of which is set to value other than Inline.

Examples
Shows how to display the shape, inside a table or outside of it.
//Document doc = new Document(MyDir + "Shape.LayoutInCell.docx");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartTable();
builder.RowFormat.Height = 100;
builder.RowFormat.HeightRule = HeightRule.Exactly;

for (int i = 0; i < 31; i++)
{
    if (i != 0 && i % 7 == 0) builder.EndRow();
    builder.InsertCell();
    builder.Write("Cell contents");
}

builder.EndTable();

NodeCollection runs = doc.GetChildNodes(NodeType.Run, true);
int num = 1;

foreach (Run run in runs.OfType<Run>())
{
    Shape watermark = new Shape(doc, ShapeType.TextPlainText);
    watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
    watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page;
    // False - display the shape outside of table cell, True - display the shape outside of table cell
    watermark.IsLayoutInCell = true; 

    watermark.Width = 30;
    watermark.Height = 30;
    watermark.HorizontalAlignment = HorizontalAlignment.Center;
    watermark.VerticalAlignment = VerticalAlignment.Center;

    watermark.Rotation = -40;
    watermark.Fill.Color = Color.Gainsboro;
    watermark.StrokeColor = Color.Gainsboro;

    watermark.TextPath.Text = string.Format("{0}", num);
    watermark.TextPath.FontFamily = "Arial";

    watermark.Name = $"WaterMark_{Guid.NewGuid()}";
    // Property will take effect only if the WrapType property is set to something other than WrapType.Inline
    watermark.WrapType = WrapType.None; 
    watermark.BehindText = true;

    builder.MoveTo(run);
    builder.InsertNode(watermark);

    num = num + 1;
}

// Behaviour of MS Word on working with shapes in table cells is changed in the last versions
// Adding the following line is needed to make the shape displayed in center of a page
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2010);

doc.Save(ArtifactsDir + "Shape.LayoutInTableCell.docx");
See Also