DocumentBuilderInsertShape Method (ShapeType, Double, Double)
Inserts inline shape with specified type and size.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.10
Syntax
public Shape InsertShape(
	ShapeType shapeType,
	double width,
	double height
)

Parameters

shapeType
Type: Aspose.Words.DrawingShapeType
The shape type to insert into the document.
width
Type: SystemDouble
The width of the shape in points.
height
Type: SystemDouble
The height of the shape in points.

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