Document Solutions for Word
Features / Shapes / Shape
In This Topic
    Shape
    In This Topic

    DsWord allows you to add predefined geometrical shapes which are visual figures with filling and outline. A few examples of shapes include rectangle, arrow, ellipse, hexagon etc. A shape can be added in a document by using Add and Insert methods of ShapeCollection class. You can also access the previous or next shapes, apply fill format, line format, group fill, shape style etc. by using methods provided by Shape class.

    DsWord supports 188 geometrical shapes which can be viewed by downloading the Word document.

    To add shape in a document:

    1. Create a new Word document by instantiating GcWordDocument class.
    2. Add a run to a newly added paragraph by using Add method of RunCollection class.
    3. Add an arc shape by using Add method of ShapeCollection class and pass GeometryType.Arc as its parameter.
    4. Set its fill formatting property and theme color by using FillType and ThemeColorId enumeration.
      C#
      Copy Code
      var doc = new GcWordDocument();
      
      //Create a Run element      
      var run = doc.Body.Paragraphs.Add().GetRange().Runs.Add();
      
      //Add an arc shape
      var shape = run.GetRange().Shapes.Add(200, 300, GeometryType.Arc);
      shape.Line.Fill.Type = FillType.Solid;
      shape.Line.Fill.SolidFill.ThemeColor = ThemeColorId.Accent4;
      
      doc.Save("shape.docx");
    Back to Top
    Note: You can also export Word document containing shapes to PDF and image formats. To know more, refer Export topic.

    Limitations

    Effects and derived classes (EffectsDAG, EffectsList) are not supported.