DocumentBuilderInsertShape Method (ShapeType, RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType)
Inserts free-floating shape with specified position, size and text wrap type.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.10
Syntax
public Shape InsertShape(
	ShapeType shapeType,
	RelativeHorizontalPosition horzPos,
	double left,
	RelativeVerticalPosition vertPos,
	double top,
	double width,
	double height,
	WrapType wrapType
)

Parameters

shapeType
Type: Aspose.Words.DrawingShapeType
The shape type to insert into the document
horzPos
Type: Aspose.Words.DrawingRelativeHorizontalPosition
Specifies where the horizontal distance to the shape is measured from.
left
Type: SystemDouble
Distance in points from the origin to the left side of the shape.
vertPos
Type: Aspose.Words.DrawingRelativeVerticalPosition
Specifies where the vertical distance to the shape is measured from.
top
Type: SystemDouble
Distance in points from the origin to the top side of the shape.
width
Type: SystemDouble
The width of the shape in points.
height
Type: SystemDouble
The width of the shape in points.
wrapType
Type: Aspose.Words.DrawingWrapType
Specifies how to wrap text around the shape.

Return Value

Type: Shape
The shape node that was inserted.
Examples
Shows how to insert DML shapes into the document using a document builder.
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// There are two ways of shape insertion
// These methods allow inserting DML shape into the document model
// Document must be saved in the format, which supports DML shapes, otherwise, such nodes will be converted
// to VML shape, while document saving

// 1. Free-floating shape insertion
Shape freeFloatingShape = builder.InsertShape(ShapeType.TopCornersRounded, RelativeHorizontalPosition.Page, 100, RelativeVerticalPosition.Page, 100, 50, 50, WrapType.None);
freeFloatingShape.Rotation = 30.0;
// 2. Inline shape insertion
Shape inlineShape = builder.InsertShape(ShapeType.DiagonalCornersRounded, 50, 50);
inlineShape.Rotation = 30.0;

// If you need to create "NonPrimitive" shapes, like SingleCornerSnipped, TopCornersSnipped, DiagonalCornersSnipped,
// TopCornersOneRoundedOneSnipped, SingleCornerRounded, TopCornersRounded, DiagonalCornersRounded
// please save the document with "Strict" or "Transitional" compliance which allows saving shape as DML
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.Docx);
saveOptions.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;

doc.Save(ArtifactsDir + "RotatedShape.docx", saveOptions);
See Also