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

Text and Graphic Properties

When using the methods of FixedContentEditor or Block classes they will create different content elements. You can control the look of the newly created elements with the following properties:

GraphicProperties

These properties are used to hold the current graphics control parameters. The following parameters can be modified using the GraphicProperties:

  • IsFilled: A boolean property specifying whether content elements should be filled.

  • IsStroked: A boolean property specifying whether content elements should be stroked.

  • FillColor: The color which will be used to fill the content elements. The property is of type ColorBase.

  • StrokeColor: The color which will be used to stroke the content elements. The property is of type ColorBase.

  • StrokeThickness: The width of the stroke outline of content elements. The property is of type double.

  • MiterLimit: Specifies the miter limit for graphic elements. The property is of type double?.

  • StrokeDashOffset: The dash array for graphic elements. The property is of type double.

  • StrokeDashArray: The stroke dash array for graphic elements. The property is of type IEnumerable<double>.

  • StrokeLineJoin: The stroke line join for graphic elements. The property is of type LineJoin.

  • StrokeLineCap: The stroke line cap for graphic elements. The property is of type LineCap.

Example 1: Using GraphicProperties with FixedContentEditor

editor.GraphicProperties.IsFilled = true; 
editor.GraphicProperties.IsStroked = true; 
 
editor.GraphicProperties.FillColor = new RgbColor(255, 0, 0); 
editor.GraphicProperties.StrokeColor = RgbColors.Black; 
editor.GraphicProperties.StrokeThickness = 2; 
editor.GraphicProperties.StrokeDashArray = new double[] { 2, 2, 5 }; 
editor.GraphicProperties.StrokeLineJoin = Telerik.Windows.Documents.Fixed.Model.Graphics.LineJoin.Round; 

TextProperties

These properties hold the parameters used for text fragments. The following parameters can be modified using the TextProperties:

  • UnderlinePattern: The underline pattern. The property is an enumeration of type UnderlinePattern. Two patterns are supported:

    • None: There is no underline. This is the default value.
    • Single: The underline is a single line.
  • UnderlineColor: The color of the underline.

  • StrikethroughPattern: The strikethrough pattern. The property is an enumeration of type StrikethroughPattern. Two patterns are supported:

    • None: There is no strikethrough. This is the default value.
    • Single: The strikethrough is a single line.
  • StrikethroughColor: The color of the strikethrough.

  • CharacterSpacing: The character spacing for text fragments. The property is of type double?.

  • WordSpacing: The word spacing for text fragments. The property is of type double?.

  • HorizontalScaling: The horizontal scaling for text fragments. The property is of type double?.

  • FontSize: The font size for text fragments. The property is of type double. The measurement unit used for font size is Device Independent Pixels (DIPs). You can convert it to points or other units using the Unit class.

  • RenderingMode: The rendering mode for text fragments. The property is of type RenderingMode.

  • BaselineAlignment: Describes how the baseline for a text-based element is positioned on the vertical axis, relative to the established baseline for text. The property is an enumeration of type BaselineAlignment and exposes the following values:

    • Baseline: A baseline that is aligned at the actual baseline of the containing box.
    • Subscript: A baseline that is aligned at the subscript position of the containing box.
    • Superscript: A baseline that is aligned at the superscript position of the containing box.
  • Font: The font for the inserted text, of type FontBase.

  • HorizontalAlignment: The horizontal positioning of the inserted text in the text block. The property is of type HorizontalAlignment.

  • VerticalAlignment: The vertical positioning of the inserted text in the text block. The property is of type VerticalAlignment.

Example 2: Using TextProperties with Block

block.TextProperties.CharacterSpacing = 5; 
block.TextProperties.Font = FontsRepository.TimesBold; 
block.TextProperties.FontSize = Unit.PointToDip(12); 
 
block.TextProperties.HighlightColor = new RgbColor(40, 60, 80); 
block.TextProperties.RenderingMode = Telerik.Windows.Documents.Fixed.Model.Text.RenderingMode.FillAndStroke; 
block.TextProperties.UnderlinePattern = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.UnderlinePattern.Single; 
block.TextProperties.UnderlineColor = RgbColors.Black;; 
The TextProperties also exposes the following methods, which can be used for changing the current font:
  • TextProperties.TrySetFont(FontFamily fontFamily);

  • TextProperties.TrySetFont(fontFamily, fontStyle, fontWeight);

Preserving Current State

Both Text and Graphic properties contain methods that can preserve and restore the current state.

  • properties.Save();

  • properties.Restore();

The Save() method returns IDisposable object that will execute Restore() as soon as the dispose method is called and can be used in a using statement.

See Also

In this article