'Create an instance of RichTextElement class
Dim rtxtElem As New Neodynamic.SDK.ImageDraw.RichTextElement
'Create TextSpan objects...
Dim ts1 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts1.FontName = "Arial"
ts1.FontSize = 14
ts1.Text = "Rich Text combines "
Dim ts2 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts2.FontName = "Tahoma"
ts2.FontSize = 14
ts2.Text = "font "
Dim ts3 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts3.FontName = "Broadway"
ts3.FontSize = 14
ts3.Text = "types and "
Dim ts4 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts4.FontName = "Arial"
ts4.FontSize = 20
ts4.Text = "sizes, new lines<br/>"
Dim ts5 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts5.FontName = "Arial"
ts5.FontSize = 14
ts5.Text = "styles like "
Dim ts6 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts6.FontName = "Arial"
ts6.FontSize = 14
ts6.FontBold = true
ts6.Text = " BOLD and "
Dim ts7 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts7.FontName = "Arial"
ts7.FontSize = 14
ts7.FontItalic = true
ts7.Text = "italic, "
Dim ts8 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts8.FontName = "Arial"
ts8.FontSize = 14
ts8.BackColor = System.Drawing.Color.Yellow
ts8.Text = "background"
Dim ts9 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts9.FontName = "Arial"
ts9.FontSize = 14
ts9.ForeColor = System.Drawing.Color.Blue
ts9.Text = " and foreground colors<br/>"
Dim ts10 As New Neodynamic.SDK.ImageDraw.TextSpan()
ts10.FontName = "Arial"
ts10.FontSize = 14
ts10.Kerning = 5
ts10.Text = "and letter spacing (kerning)"
'Set RicText property
rtxtElem.RichText = ts1.ToString() + ts2.ToString() + ts3.ToString() + _
ts4.ToString() + ts5.ToString() + ts6.ToString() + _
ts7.ToString() + ts8.ToString() + ts9.ToString() + _
ts10.ToString()
//Create an instance of RichTextElement class
Neodynamic.SDK.ImageDraw.RichTextElement rtxtElem = new Neodynamic.SDK.ImageDraw.RichTextElement();
//Create TextSpan objects...
Neodynamic.SDK.ImageDraw.TextSpan ts1 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts1.FontName = "Arial";
ts1.FontSize = 14;
ts1.Text = "Rich Text combines ";
Neodynamic.SDK.ImageDraw.TextSpan ts2 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts2.FontName = "Tahoma";
ts2.FontSize = 14;
ts2.Text = "font ";
Neodynamic.SDK.ImageDraw.TextSpan ts3 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts3.FontName = "Broadway";
ts3.FontSize = 14;
ts3.Text = "types and ";
Neodynamic.SDK.ImageDraw.TextSpan ts4 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts4.FontName = "Arial";
ts4.FontSize = 20;
ts4.Text = "sizes, new lines<br/>";
Neodynamic.SDK.ImageDraw.TextSpan ts5 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts5.FontName = "Arial";
ts5.FontSize = 14;
ts5.Text = "styles like ";
Neodynamic.SDK.ImageDraw.TextSpan ts6 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts6.FontName = "Arial";
ts6.FontSize = 14;
ts6.FontBold = true;
ts6.Text = " BOLD and ";
Neodynamic.SDK.ImageDraw.TextSpan ts7 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts7.FontName = "Arial";
ts7.FontSize = 14;
ts7.FontItalic = true;
ts7.Text = "italic, ";
Neodynamic.SDK.ImageDraw.TextSpan ts8 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts8.FontName = "Arial";
ts8.FontSize = 14;
ts8.BackColor = System.Drawing.Color.Yellow;
ts8.Text = "background";
Neodynamic.SDK.ImageDraw.TextSpan ts9 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts9.FontName = "Arial";
ts9.FontSize = 14;
ts9.ForeColor = System.Drawing.Color.Blue;
ts9.Text = " and foreground colors<br/>";
Neodynamic.SDK.ImageDraw.TextSpan ts10 = new Neodynamic.SDK.ImageDraw.TextSpan();
ts10.FontName = "Arial";
ts10.FontSize = 14;
ts10.Kerning = 5;
ts10.Text = "and letter spacing (kerning)";
//Set RichText property
rtxtElem.RichText = ts1.ToString() + ts2.ToString() + ts3.ToString() +
ts4.ToString() + ts5.ToString() + ts6.ToString() +
ts7.ToString() + ts8.ToString() + ts9.ToString() +
ts10.ToString();
RichTextElement
A
RichTextElement – represented by
Neodynamic.SDK.ImageDraw.RichTextElement class – lets you to render rich text by mixing words in different fonts, sizes, capitalizations, foreground colors, etc.
Rich Text Features
The RichTextElement class features a property named
RichText which must be set up with a string containing the
ImageDraw rich text markup. ImageDraw rich text markup is composed of
TextSpan objects. A TextSpan object is used to indicate a text inline container within the whole rich text content.
The TextSpan object features the following markup:
<TextSpan FontName=""
FontUnit=""
FontSize=""
FontBold=""
FontItalic=""
FontUnderline=""
FontStrikeout=""
CustomFontFile=""
CustomFontFileFamilyIndex=""
ForeColor=""
BackColor=""
BaselineOffset=""
Kerning=""
Text="" />
Description of each attributes/properties of the TextSpan object:
- FontName
It specifies the font face name. It must be one of the fonts' name registered in Windows OS. Default value is Arial.
- FontUnit
It specifies the unit of measure for the font. It must be a value of System.Drawing.GraphicsUnit enumeration. Default value is Point.
- FontSize
It specifies the size of the font. Default value is 8
- FontBold
It specifies whether the font is bold. Default value is False.
- FontItalic
It specifies whether the font is italic. Default value is False.
- FontUnderline
It specifies whether the font is underlined. Default value is False.
- FontStrikeout
It specifies whether the font draws a horizontal line through the text. Default value is False.
- CustomFontFile
It specifies the custom font file (*.TTF). It can be specified as a relative URL or full path pointing out to the custom font file on local disk or; as an identifier stored in the appSettings section of Web.config file. Default value is an empty string meaning that no custom font will be used.
- CustomFontFileFamilyIndex
It specifies the Font Family index of the typefaces defined by the specified Custom Font File. Default value is 0 (zero)
- ForeColor
It specified the foreground color. Default value is Black.
- BackColor
It specifies the background color. Default value is Transparent.
- BaselineOffset
It specifies a vertical offset value for the baseline of the TextSpan. Default value is 0 (zero)
- Kerning
It specifies the spacing between the letters contained in the TextSpan. Default value is 0 (zero)
- Text
It specifies the text to be rendered by the TextSpan. Default value is an empty string. NOTE: for new line breaks you must use <BR/> inside the content of this property.
Syntax sample:
TextElement Output Sample:
Applying Actions (Imaging Effects) on RichTextElement objects
RichTextElement can be "affected" by more than one
Action due to it features an
Actions property of type
Neodynamic.SDK.ImageDraw.ActionCollection.
Learn more about Actions.