ShapeBaseCoordSize Property

The width and height of the coordinate space inside the containing block of this shape.

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

Property Value

Type: Size
Remarks

The default value is (1000, 1000).

Examples
Shows how to create and work with a group of shapes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Every GroupShape is top level
GroupShape group = new GroupShape(doc);
Assert.True(group.IsGroup);
Assert.True(group.IsTopLevel);

// And it is a floating shape too, so we can set its coordinates independently of the text
Assert.AreEqual(WrapType.None, group.WrapType);

// Make it a floating shape
group.WrapType = WrapType.None;

// Top level shapes can have this property changed
group.AnchorLocked = true;

// Set the XY coordinates of the shape group and the size of its containing block, as it appears on the page
group.Bounds = new RectangleF(100, 50, 200, 100);

// Set the scale of the inner coordinates of the shape group
// These values mean that the bottom right corner of the 200x100 outer block we set before
// will be at x = 2000 and y = 1000, or 2000 units from the left and 1000 units from the top
group.CoordSize = new Size(2000, 1000);

// The coordinate origin of a shape group is x = 0, y = 0 by default, which is the top left corner
// If we insert a child shape and set its distance from the left to 2000 and the distance from the top to 1000,
// its origin will be at the bottom right corner of the shape group
// We can offset the coordinate origin by setting the CoordOrigin attribute
// In this instance, we move the origin to the centre of the shape group
group.CoordOrigin = new Point(-1000, -500);

// Populate the shape group with child shapes
// First, insert a rectangle
Shape subShape = new Shape(doc, ShapeType.Rectangle);
subShape.Width = 500;
subShape.Height = 700;

// Place its top left corner at the parent group's coordinate origin, which is currently at its centre
subShape.Left = 0;
subShape.Top = 0;

// Add the rectangle to the group
group.AppendChild(subShape);

// Insert a triangle
subShape = new Shape(doc, ShapeType.Triangle);
subShape.Width = 400;
subShape.Height = 400;

// Place its origin at the bottom right corner of the group
subShape.Left = 1000;
subShape.Top = 500;

// The offset between this child shape and parent group can be seen here
Assert.AreEqual(new PointF(1000, 500), subShape.LocalToParent(new PointF(0, 0)));

// Add the triangle to the group
group.AppendChild(subShape);

// Child shapes of a group shape are not top level
Assert.False(subShape.IsTopLevel);

// Finally, insert the group into the document and save
builder.InsertNode(group);
doc.Save(ArtifactsDir + "Shape.InsertGroupShape.docx");
See Also