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: 19.12
public bool IsLayoutInCell { get; set; }

Property Value

Type: Boolean

The default value is true.

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

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

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;
    watermark.IsLayoutInCell =
        true; // False - display the shape outside of table cell, True - display the shape outside of table cell

    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 = string.Format("WaterMark_{0}", Guid.NewGuid());
    watermark.WrapType =
        WrapType.None; // Property will take effect only if the WrapType property is set to something other than WrapType.Inline
    watermark.BehindText = true;


    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.Save(ArtifactsDir + "Shape.LayoutInCell.docx");
See Also