Xceed Words for .NET v3.0 Documentation
AddShape Method
Example 


Xceed.Document.NET Assembly > Xceed.Document.NET Namespace > Document Class : AddShape Method
The width of the Shape (in points).
The height of the Shape (in points).
The Color used to fill the Shape. If not defined, blue("4472C4") is used.
The Color used for the outline of the Shape. If not defined, dark blue("2F528F") is used.
The width used for the outline of the Shape (in points). If not defined, 1 is used.
The dash style used for the outline of the Shape. If not defined, Solid is used.
Adds a Shape to a Document.
Syntax
'Declaration
 
Public Function AddShape( _

   ByVal width As Single, _

   ByVal height As Single, _

   Optional ByVal fillColor As Nullable(Of Color), _

   Optional ByVal outlineColor As Nullable(Of Color), _

   Optional ByVal outlineWidth As Single, _

   Optional ByVal outlineDash As Nullable(Of DashStyle) _

) As Shape
'Usage
 
Dim instance As Document

Dim width As Single

Dim height As Single

Dim fillColor As Nullable(Of Color)

Dim outlineColor As Nullable(Of Color)

Dim outlineWidth As Single

Dim outlineDash As Nullable(Of DashStyle)

Dim value As Shape

 

value = instance.AddShape(width, height, fillColor, outlineColor, outlineWidth, outlineDash)

Parameters

width
The width of the Shape (in points).
height
The height of the Shape (in points).
fillColor
The Color used to fill the Shape. If not defined, blue("4472C4") is used.
outlineColor
The Color used for the outline of the Shape. If not defined, dark blue("2F528F") is used.
outlineWidth
The width used for the outline of the Shape (in points). If not defined, 1 is used.
outlineDash
The dash style used for the outline of the Shape. If not defined, Solid is used.

Return Value

The newly created Shape.
Remarks

Currently, the Shape can only be a Rectangle.

To add a TextBox Shape, use the AddTextBox method.

Example
// Create a document.

using (var document = DocX.Create("Test.docx"))

{

  // Create a shape and add it to the document.

  var shape = document.AddShape( 50, 50, Color.LightGray );

  shape.OutlineColor = Color.Green;



  // Create a new Paragraph.

  var p = document.InsertParagraph();



  // Append content to the Paragraph.

  p.Append( "Here is a cool shape" )

    .AppendShape( shape )

    .Append( " don't you think so?" );



  // Save all changes made to this document.

  document.Save();

}
Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows, 11, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Document Class
Document Members