Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Path

Path is a content element that represents series of connected lines and curves. The shape of the path is specified by its Geometry property.

Inserting a Path

Path is a content element that is designed to be added in the Content collection of an IContainerElement such RadFixedPage. There are several approaches, which you can adopt to achieve that.

Example 1 shows how you can create a Path, assign a predefined Geometry to it and add it to a container.

Example 1: Create Path and add it to container

Path path = new Path(); 
path.Geometry = geometry; 
container.Content.Add(path); 

Example 2 demonstrates how to use one of the factory methods of the ContentElementCollection that create a new path and insert it into the document.

Example 2: Add Path to container

Path path = container.Content.AddPath(); 
path.Geometry = geometry; 

There are other methods that allow adding a path to a document. They could be used through the FixedContentEditor class.

Modifying a Path

You can modify a Path element using the properties the class exposes. The properties are listed below.

  • Fill: The color that is used to fill the path. The default value is Black.

  • Stroke: The color that is used to stroke the path. The default value is Black.

  • IsFilled: Specifies whether the path should be filled.

  • IsStroked: Specifies whether the path should be stroked.

  • StrokeThickness: The width of the stroke outline.

  • StrokeLineCap: Specifies the shape, which is used at the ends of open paths when they are stroked.

    • Flat: Flat line cap.

    • Round: Round line cap.

    • Square: Square line cap.

  • StrokeLineJoin: Specifies the shape to be used at the corners of paths that are stroked. Join styles are significant only at the points where consecutive segments of a path connect at an angle.

    • Bevel: Produces a diagonal corner.

    • Miter: Produces a sharp corner. If the segments meet at too sharp angle, a bevel join is used instead.

    • Round: Produces a smooth, circular arc between the lines.

  • StrokeDashArray: The pattern of dashes and gaps used to stroke paths.

  • StrokeDashOffset: The distance from the start of a line to the beginning of a dash pattern.

  • AlphaConstant: Specifying the constant shape or constant opacity value to be used for nonstroking operations.

  • StrokeAlphaConstant: Specifying the constant shape or constant opacity value to be used for nonstroking operations.

  • MiterLimit: The limit of the thickness of the join on a mitered corner.

  • Geometry: The shape to be drawn. More information about geometries is available here.

Example 3: Modifying Path properties

RadFixedDocument document = new RadFixedDocument(); 
RadFixedPage page = document.Pages.AddPage(); 
FixedContentEditor editor = new FixedContentEditor(page); 
 
RectangleGeometry rectangleGeometry = new RectangleGeometry(); 
rectangleGeometry.Rect = new Rect(10, 5, 400, 300); 
 
Telerik.Windows.Documents.Fixed.Model.Graphics.Path path = new Telerik.Windows.Documents.Fixed.Model.Graphics.Path(); 
path.Geometry = rectangleGeometry; 
 
SimplePosition simplePosition = new SimplePosition(); 
simplePosition.Translate(20, 20); 
 
path.Fill = new RgbColor(255, 0, 255); 
path.Stroke = new RgbColor(0, 0, 255); 
path.IsFilled = true; 
path.IsStroked = true; 
path.StrokeThickness = 1; 
path.StrokeLineCap = Telerik.Windows.Documents.Fixed.Model.Graphics.LineCap.Flat; 
path.StrokeLineJoin = Telerik.Windows.Documents.Fixed.Model.Graphics.LineJoin.Round; 
path.StrokeDashArray = new double[] { 1 }; 
path.StrokeDashOffset = 2; 
path.AlphaConstant = 0.5; 
path.StrokeAlphaConstant = 0.1; 
path.MiterLimit = 2; 
path.Position = simplePosition; 
 
page.Content.Add(path); 

See Also

In this article