ShapeStroke Property
Defines a stroke for a shape.

Namespace: Aspose.Words.Drawing
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public Stroke Stroke { get; }

Property Value

Type: Stroke
Examples
Shows to create a variety of shapes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Draw a dotted horizontal half-transparent red line with an arrow on the left end and a diamond on the other
Shape arrow = new Shape(doc, ShapeType.Line);
arrow.Width = 200;
arrow.Stroke.Color = Color.Red;
arrow.Stroke.StartArrowType = ArrowType.Arrow;
arrow.Stroke.StartArrowLength = ArrowLength.Long;
arrow.Stroke.StartArrowWidth = ArrowWidth.Wide;
arrow.Stroke.EndArrowType = ArrowType.Diamond;
arrow.Stroke.EndArrowLength = ArrowLength.Long;
arrow.Stroke.EndArrowWidth = ArrowWidth.Wide;
arrow.Stroke.DashStyle = DashStyle.Dash;
arrow.Stroke.Opacity = 0.5;

Assert.AreEqual(JoinStyle.Miter, arrow.Stroke.JoinStyle);

builder.InsertNode(arrow);

// Draw a thick black diagonal line with rounded ends
Shape line = new Shape(doc, ShapeType.Line);
line.Top = 40;
line.Width = 200;
line.Height = 20;
line.StrokeWeight = 5.0;
line.Stroke.EndCap = EndCap.Round;

builder.InsertNode(line);

// Draw an arrow with a green fill
Shape filledInArrow = new Shape(doc, ShapeType.Arrow);
filledInArrow.Width = 200;
filledInArrow.Height = 40;
filledInArrow.Top = 100;
filledInArrow.Fill.Color = Color.Green;
filledInArrow.Fill.On = true;

builder.InsertNode(filledInArrow);

// Draw an arrow filled in with the Aspose logo and flip its orientation
Shape filledInArrowImg = new Shape(doc, ShapeType.Arrow);
filledInArrowImg.Width = 200;
filledInArrowImg.Height = 40;
filledInArrowImg.Top = 160;
filledInArrowImg.FlipOrientation = FlipOrientation.Both;

using (WebClient webClient = new WebClient())
{
    byte[] imageBytes = webClient.DownloadData(AsposeLogoUrl);

    using (System.IO.MemoryStream stream = new System.IO.MemoryStream(imageBytes))
    {
        Image image = Image.FromStream(stream);
        // When we flipped the orientation of our arrow, the image content was flipped too
        // If we want it to be displayed the right side up, we have to reverse the arrow flip on the image
        image.RotateFlip(RotateFlipType.RotateNoneFlipXY);

        filledInArrowImg.ImageData.SetImage(image);
        filledInArrowImg.Stroke.JoinStyle = JoinStyle.Round;

        builder.InsertNode(filledInArrowImg);
    }
}

doc.Save(ArtifactsDir + "Drawing.VariousShapes.docx");
See Also