DocumentBuilderInsertShape Method (ShapeType, Double, Double) |
Namespace: Aspose.Words
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 + "Shape.ShapeInsertion.docx", saveOptions);