Click or drag to resize

Pen Class

Represents a type which describes how a shape is outlined.
Inheritance Hierarchy
SystemObject
  SautinSoft.Document.DrawingPen

Namespace: SautinSoft.Document.Drawing
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.1.24
Syntax
public sealed class Pen

The Pen type exposes the following members.

Properties
 NameDescription
Public propertyCapStyle Gets or sets the cap style for the end of a stroke.
Public propertyDashStyle Gets or sets the dot and dash pattern for a stroke.
Public propertyFill Gets the fill of the outline.
Public propertyHeadEnd Gets or sets the decoration which will be added to the head of a line.
Public propertyHeadEndLength Gets or sets the line head-end length in relation to the line width.
Public propertyHeadEndWidth Gets or sets the line head-end width in relation to the line width.
Public propertyJoinStyle Gets or sets the join style of a polyline.
Public propertyTailEnd Gets or sets the decoration which will be added to the tail of a line.
Public propertyTailEndLength Gets or sets the line tail-end length in relation to the line width.
Public propertyTailEndWidth Gets or sets the line tail-end width in relation to the line width.
Public propertyWidth Gets or sets the thickness of the stroke.
Top
Example

See Developer Guide: Creates a new document with shape containing a text and picture

Creates a new document with shape containing a text and picture using C#
using SautinSoft.Document;
using SautinSoft.Document.Drawing;

namespace Example
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get your free 30-day key here:   
            // https://sautinsoft.com/start-for-free/

            PictureAndShape();
        }
        /// <summary>
        /// Creates a new document with shape containing a text and picture.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/pictures-and-shapes.php
        /// </remarks>
        static void PictureAndShape()
        {
            string filePath = @"Shape.docx";
            string imagePath = @"..\..\..\image.jpg";

            DocumentCore dc = new DocumentCore();                        

            // 1. Shape with text.
            Shape shapeWithText = new Shape(dc, Layout.Floating(new HorizontalPosition(1, LengthUnit.Inch, HorizontalPositionAnchor.Page), 
                new VerticalPosition(2, LengthUnit.Inch, VerticalPositionAnchor.Page),
                new Size(LengthUnitConverter.Convert(6, LengthUnit.Inch, LengthUnit.Point), LengthUnitConverter.Convert(1.5d, LengthUnit.Centimeter, LengthUnit.Point))));
            (shapeWithText.Layout as FloatingLayout).WrappingStyle = WrappingStyle.InFrontOfText;
            shapeWithText.Text.Blocks.Add(new Paragraph(dc, new Run(dc, "This is the text in shape.", new CharacterFormat() { Size  = 30})));
            shapeWithText.Outline.Fill.SetEmpty();
            shapeWithText.Fill.SetSolid(Color.Orange);
            dc.Content.End.Insert(shapeWithText.Content);            

            // 2. Picture with FloatingLayout:
            // Floating layout means that the Picture (or Shape) is positioned by coordinates.
            Picture pic = new Picture(dc, imagePath);
            pic.Layout = FloatingLayout.Floating(
                new HorizontalPosition(50, LengthUnit.Millimeter, HorizontalPositionAnchor.Page),
                new VerticalPosition(20, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin),
                new Size(LengthUnitConverter.Convert(10, LengthUnit.Centimeter, LengthUnit.Point),
                         LengthUnitConverter.Convert(10, LengthUnit.Centimeter, LengthUnit.Point))
                         );

            // Set the wrapping style.
            (pic.Layout as FloatingLayout).WrappingStyle = WrappingStyle.BehindText;

            // Add our picture into the section.
            dc.Content.End.Insert(pic.Content);

            dc.Save(filePath);

            // Show the result.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
        }
    }
}
Creates a new document with shape containing a text and picture using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Imports SautinSoft.Document.Drawing

Module Sample
    Sub Main()
        PictureAndShape()
    End Sub
    ''' Get your free 30-day key here:   
    ''' https://sautinsoft.com/start-for-free/
    ''' <summary>
    ''' Creates a new document with shape containing a text and picture.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/pictures-and-shapes.php
    ''' </remarks>
    Sub PictureAndShape()
        Dim filePath As String = "Shape.docx"
        Dim imagePath As String = "..\..\..\image.jpg"

        Dim dc As New DocumentCore()

        ' 1. Shape with text.
        Dim shapeWithText As New Shape(dc, Layout.Floating(New HorizontalPosition(1, LengthUnit.Inch, HorizontalPositionAnchor.Page), New VerticalPosition(2, LengthUnit.Inch, VerticalPositionAnchor.Page), New Size(LengthUnitConverter.Convert(6, LengthUnit.Inch, LengthUnit.Point), LengthUnitConverter.Convert(1.5R, LengthUnit.Centimeter, LengthUnit.Point))))
        TryCast(shapeWithText.Layout, FloatingLayout).WrappingStyle = WrappingStyle.InFrontOfText
        shapeWithText.Text.Blocks.Add(New Paragraph(dc, New Run(dc, "This is the text in shape.", New CharacterFormat() With {.Size = 30})))
        shapeWithText.Outline.Fill.SetEmpty()
        shapeWithText.Fill.SetSolid(Color.Orange)
        dc.Content.End.Insert(shapeWithText.Content)

        ' 2. Picture with FloatingLayout:
        ' Floating layout means that the Picture (or Shape) is positioned by coordinates.
        Dim pic As New Picture(dc, imagePath)
        pic.Layout = FloatingLayout.Floating(New HorizontalPosition(50, LengthUnit.Millimeter, HorizontalPositionAnchor.Page), New VerticalPosition(20, LengthUnit.Millimeter, VerticalPositionAnchor.TopMargin), New Size(LengthUnitConverter.Convert(10, LengthUnit.Centimeter, LengthUnit.Point), LengthUnitConverter.Convert(10, LengthUnit.Centimeter, LengthUnit.Point)))

        ' Set the wrapping style.
        TryCast(pic.Layout, FloatingLayout).WrappingStyle = WrappingStyle.BehindText

        ' Add our picture into the section.
        dc.Content.End.Insert(pic.Content)

        dc.Save(filePath)

        ' Show the result.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
    End Sub
End Module
See Also