ShapeBaseBounds Property

Gets or sets the location and size of the containing block of the shape.

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

Property Value

Type: RectangleF
Remarks
Ignores aspect ratio lock upon setting.
Remarks

For a top-level shape, the value is in points and relative to the shape anchor.

For shapes in a group, the value is in the coordinate space and units of the parent group.

Examples
Shows how to create line shapes and set specific location and size.
Document doc = new Document();

// The lines will cross the whole page
float pageWidth = (float) doc.FirstSection.PageSetup.PageWidth;
float pageHeight = (float) doc.FirstSection.PageSetup.PageHeight;

// This line goes from top left to bottom right by default
Shape lineA = new Shape(doc, ShapeType.Line)
{
    Bounds = new RectangleF(0, 0, pageWidth, pageHeight),
    RelativeHorizontalPosition = RelativeHorizontalPosition.Page,
    RelativeVerticalPosition = RelativeVerticalPosition.Page
};

Assert.AreEqual(new RectangleF(0, 0, pageWidth, pageHeight), lineA.BoundsInPoints);

// This line goes from bottom left to top right because we flipped it
Shape lineB = new Shape(doc, ShapeType.Line)
{
    Bounds = new RectangleF(0, 0, pageWidth, pageHeight),
    FlipOrientation = FlipOrientation.Horizontal,
    RelativeHorizontalPosition = RelativeHorizontalPosition.Page,
    RelativeVerticalPosition = RelativeVerticalPosition.Page
};

Assert.AreEqual(new RectangleF(0, 0, pageWidth, pageHeight), lineB.BoundsInPoints);

// Add lines to the document
doc.FirstSection.Body.FirstParagraph.AppendChild(lineA);
doc.FirstSection.Body.FirstParagraph.AppendChild(lineB);

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