ShapeBaseTop Property

Gets or sets the position of the top edge of the containing block of the shape.

Namespace:  Aspose.Words.Drawing
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.5
public double Top { get; set; }

Property Value

Type: Double

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.

The default value is 0.

Has effect only for floating shapes.

Shows how to insert a floating image and specify its position and size.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// By default, the image is inline
Shape shape = builder.InsertImage(ImageDir + "Logo.jpg");

// Make the image float, put it behind text and center on the page
shape.WrapType = WrapType.None;

// Make position relative to the page
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;

// Set the shape's coordinates, from the top left corner of the page
shape.Left = 100;
shape.Top = 80;

// Set the shape's height
shape.Height = 125.0;

// The width will be scaled to the height and the dimensions of the real image
Assert.AreEqual(125.0, shape.Width);

// The Bottom and Right members contain the locations of the bottom and right edges of the image
Assert.AreEqual(shape.Top + shape.Height, shape.Bottom);
Assert.AreEqual(shape.Left + shape.Width, shape.Right);

doc.Save(ArtifactsDir + "Image.CreateFloatingPositionSize.docx");
See Also