Class WCharacterFormat
Represents the font or character properties of the text in the Word document.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class WCharacterFormat : FormatBase, IXDLSSerializable, IOfficeRunFormat
Examples
The following examples illustrates how to apply various character formats for the text.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text to the paragraph
IWTextRange text = paragraph.AppendText("Text with All caps.");
//All Caps
text.CharacterFormat.AllCaps = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Right to left text.");
//Right to left text with bold and italic styles.
text.CharacterFormat.Bidi = true;
text.CharacterFormat.FontNameBidi = "Times New Roman";
text.CharacterFormat.FontSizeBidi = 14;
text.CharacterFormat.BoldBidi = true;
text.CharacterFormat.ItalicBidi = true;
paragraph = section.AddParagraph();
//Bold
text = paragraph.AppendText("Bold text.");
text.CharacterFormat.Bold = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Text with border.");
//Borders
text.CharacterFormat.Border.BorderType = BorderStyle.DotDash;
text.CharacterFormat.Border.LineWidth = 0.5f;
text.CharacterFormat.Border.Color = Color.Blue;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Character spacing.");
text.CharacterFormat.CharacterSpacing = 1;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Double strike.");
//Double strike
text.CharacterFormat.DoubleStrike = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Emboss.");
//Emboss
text.CharacterFormat.Emboss = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Engrave.");
//Engrave
text.CharacterFormat.Engrave = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Font name.");
//Font name
text.CharacterFormat.FontName = "Algerian";
paragraph = section.AddParagraph();
text = paragraph.AppendText("Font size.");
//Font size
text.CharacterFormat.FontSize = 10;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Highlight color.");
//Highlight color
text.CharacterFormat.HighlightColor = Color.Gray;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Italic.");
//Italic
text.CharacterFormat.Italic = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Outline.");
//Outline
text.CharacterFormat.OutLine = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Position Property with text");
text = paragraph.AppendText("raised by 10 points.");
//Position
text.CharacterFormat.Position = 10;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Shadow.");
//Shadow
text.CharacterFormat.Shadow = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("SmallCaps.");
//SmallCaps
text.CharacterFormat.SmallCaps = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Strikeout.");
//Strikeout
text.CharacterFormat.Strikeout = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Text");
text = paragraph.AppendText("Subscript.");
//Subscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SubScript;
paragraph = section.AddParagraph();
paragraph.AppendText("Text");
text = paragraph.AppendText("Superscript.");
//Superscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
paragraph = section.AddParagraph();
text = paragraph.AppendText("TextBackgroundColor.");
//TextBackgroundColor
text.CharacterFormat.TextBackgroundColor = Color.LightSkyBlue;
paragraph = section.AddParagraph();
text = paragraph.AppendText("TextColor.");
//TextColor
text.CharacterFormat.TextColor = Color.Green;
paragraph = section.AddParagraph();
text = paragraph.AppendText("UnderlineStyle.");
//UnderlineStyle
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text to the paragraph
Dim text As IWTextRange = paragraph.AppendText("Text with All caps.")
'All Caps
text.CharacterFormat.AllCaps = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Right to left text.")
'Right to left text with bold and italic styles.
text.CharacterFormat.Bidi = True
text.CharacterFormat.FontNameBidi = "Times New Roman"
text.CharacterFormat.FontSizeBidi = 14
text.CharacterFormat.BoldBidi = True
text.CharacterFormat.ItalicBidi = True
paragraph = section.AddParagraph()
'Bold
text = paragraph.AppendText("Bold text.")
text.CharacterFormat.Bold = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Text with border.")
'Borders
text.CharacterFormat.Border.BorderType = BorderStyle.DotDash
text.CharacterFormat.Border.LineWidth = 0.5F
text.CharacterFormat.Border.Color = Color.Blue
paragraph = section.AddParagraph()
text = paragraph.AppendText("Character spacing.")
text.CharacterFormat.CharacterSpacing = 1
paragraph = section.AddParagraph()
text = paragraph.AppendText("Double strike.")
'Double strike
text.CharacterFormat.DoubleStrike = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Emboss.")
'Emboss
text.CharacterFormat.Emboss = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Engrave.")
'Engrave
text.CharacterFormat.Engrave = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Font name.")
'Font name
text.CharacterFormat.FontName = "Algerian"
paragraph = section.AddParagraph()
text = paragraph.AppendText("Font size.")
'Font size
text.CharacterFormat.FontSize = 10
paragraph = section.AddParagraph()
text = paragraph.AppendText("Highlight color.")
'Highlight color
text.CharacterFormat.HighlightColor = Color.Gray
paragraph = section.AddParagraph()
text = paragraph.AppendText("Italic.")
'Italic
text.CharacterFormat.Italic = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Outline.")
'Outline
text.CharacterFormat.OutLine = True
paragraph = section.AddParagraph()
paragraph.AppendText("Position Property with text")
text = paragraph.AppendText("raised by 10 points.")
'Position
text.CharacterFormat.Position = 10
paragraph = section.AddParagraph()
text = paragraph.AppendText("Shadow.")
'Shadow
text.CharacterFormat.Shadow = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("SmallCaps.")
'SmallCaps
text.CharacterFormat.SmallCaps = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Strikeout.")
'Strikeout
text.CharacterFormat.Strikeout = True
paragraph = section.AddParagraph()
paragraph.AppendText("Text")
text = paragraph.AppendText("Subscript.")
'Subscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SubScript
paragraph = section.AddParagraph()
paragraph.AppendText("Text")
text = paragraph.AppendText("Superscript.")
'Superscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SuperScript
paragraph = section.AddParagraph()
text = paragraph.AppendText("TextBackgroundColor.")
'TextBackgroundColor
text.CharacterFormat.TextBackgroundColor = Color.LightSkyBlue
paragraph = section.AddParagraph()
text = paragraph.AppendText("TextColor.")
'TextColor
text.CharacterFormat.TextColor = Color.Green
paragraph = section.AddParagraph()
text = paragraph.AppendText("UnderlineStyle.")
'UnderlineStyle
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
WCharacterFormat(IWordDocument)
Initializes a new instance of the WCharacterFormat class with the specified IWordDocument instance.
Declaration
public WCharacterFormat(IWordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
IWordDocument | doc | The IWordDocument instance. |
Fields
m_charStyleName
Member that specifies the character style name.
Declaration
protected string m_charStyleName
Field Value
Type |
---|
System.String |
m_symExFontName
Declaration
protected string m_symExFontName
Field Value
Type |
---|
System.String |
Properties
AllCaps
Gets or sets a value indicating whether the text characters are displayed as their capital letter equivalents.
Declaration
public bool AllCaps { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text to be displayed as capital letters; otherwise, false. |
Bidi
Gets or sets a value indicating whether the text is formatted with right-to-left layout.
Declaration
public bool Bidi { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text is right-to-left; otherwise, false. |
Bold
Gets or sets a value indicating whether the text is formatted as bold.
Declaration
public bool Bold { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to format the text with bold style; otherwise, false. |
BoldBidi
Gets or sets a value indicating whether the text is formatted bold when displayed right-to-left or determined to be complex script.
Declaration
public bool BoldBidi { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to format the right-to-left text with bold style; otherwise, false. |
Border
Gets the Border for the text.
Declaration
public Border Border { get; }
Property Value
Type |
---|
Border |
CharacterSpacing
Gets or sets space width between the characters measured in points.
Declaration
public float CharacterSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the width. |
CharStyleName
Gets the character style name that is used to format the contents of the paragraph.
Declaration
public string CharStyleName { get; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the character style name. |
ComplexScript
Gets or sets a value indicating whether the contents of the text shall be treated as complex script text regardless of their Unicode character values when determining the formatting for the text.
Declaration
public bool ComplexScript { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to consider as complex script; otherwise, false. |
DoubleStrike
Gets or sets a value indicating whether the text is formatted with double strikethrough effect.
Declaration
public bool DoubleStrike { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to format the text with double strike through; otherwise, false. |
Remarks
The double strike effect is not supported by Essential PDF.
Emboss
Gets or sets a value indicating whether the text is embossed.
Declaration
public bool Emboss { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text is embossed; otherwise, false. |
Engrave
Gets or sets a value indicating whether the text is engraved.
Declaration
public bool Engrave { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text is engraved; otherwise, false. |
Font
Gets or sets font for the text.
Declaration
public Font Font { get; set; }
Property Value
Type |
---|
Font |
FontName
Gets or sets font name of the text.
Declaration
public string FontName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the font name. |
FontNameBidi
Gets or sets the font name for text that is displayed right-to-left or text that is a complex script.
Declaration
public string FontNameBidi { get; set; }
Property Value
Type |
---|
System.String |
FontSize
Gets or sets the font size of the text measured in points.
Declaration
public float FontSize { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the font size. |
FontSizeBidi
Gets or sets the size of the text(in points), for text that is displayed right-to-left or text that is a complex script.
Declaration
public float FontSizeBidi { get; set; }
Property Value
Type |
---|
System.Single |
Hidden
Gets or sets a value indicating whether the text is formatted as hidden.
Declaration
public bool Hidden { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text is hidden; otherwise, false. |
HighlightColor
Gets or sets highlight System.Drawing.Color of the text.
Declaration
public Color HighlightColor { get; set; }
Property Value
Type |
---|
Color |
Remarks
Microsoft Word application supports only 15 valid colors for highlighting the text.
To highlight text with Microsoft Word compatible color in the generated Word document, use the known color object or new color object with same ARGB value based on the following highlight color mapping.
Yellow Color.Yellow (#FFFFFF00)
BrightGreen Color.Green (#FF008000)
Turquoise Color.Cyan (#FF00FFFF)
Pink Color.Magenta (#FFFF00FF)
Blue Color.Blue (#FF0000FF)
Red Color.Red (#FFFF0000)
DarkBlue Color.DarkBlue (#FF00008B)
Teal Color.DarkCyan (#FF008B8B)
Green Color.DarkGreen (#FF006400)
Violet Color.DarkMagenta (#FF8B008B)
DarkRed Color.DarkRed (#FF8B0000)
DarkYellow Color.Gold (#FFFFD700)
Gray50 Color.DarkGray (#FFA9A9A9)
Gray25 Color.LightGray (#FFD3D3D3)
Black Color.Black (#FF000000)
No Color Color.Empty
Italic
Gets or sets a value indicating whether the text is formatted as italic.
Declaration
public bool Italic { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to format the text with italic style; otherwise, false. |
ItalicBidi
Gets or sets a value indicating whether the text is italicized when displayed right-to-left or determined to be complex script.
Declaration
public bool ItalicBidi { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to format the right-to-left text with italic style; otherwise, false. |
Ligatures
Gets or sets the ligatures type for the text.
Declaration
public LigatureType Ligatures { get; set; }
Property Value
Type | Description |
---|---|
LigatureType | The LigatureType member that specifies the type of ligatures. |
Examples
The following example illustrates how to set ligature types for text.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe discretional ligatures");
//Set ligature type
text.CharacterFormat.Ligatures = LigatureType.Discretional;
text.CharacterFormat.FontName = "Arial";
paragraph = section.AddParagraph();
text = paragraph.AppendText("Text to describe contextual ligatures");
text.CharacterFormat.Ligatures = LigatureType.Contextual;
text.CharacterFormat.FontName = "Arial";
paragraph = section.AddParagraph();
text = paragraph.AppendText("Text to describe historical ligatures");
text.CharacterFormat.Ligatures = LigatureType.Historical;
text.CharacterFormat.FontName = "Arial";
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe discretional ligatures")
'Set ligature type as Discretional
text.CharacterFormat.Ligatures = LigatureType.Discretional
text.CharacterFormat.FontName = "Arial"
paragraph = section.AddParagraph()
text = paragraph.AppendText("Text to describe contextual ligatures")
'Set ligature type as Contextual
text.CharacterFormat.Ligatures = LigatureType.Contextual
text.CharacterFormat.FontName = "Arial"
paragraph = section.AddParagraph()
text = paragraph.AppendText("Text to describe historical ligatures")
'Set ligature type as Historical
text.CharacterFormat.Ligatures = LigatureType.Historical
text.CharacterFormat.FontName = "Arial"
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
LocaleIdASCII
Gets or sets the locale identifier(language) of the formatted characters.
Declaration
public short LocaleIdASCII { get; set; }
Property Value
Type | Description |
---|---|
System.Int16 | The short value that specifies the ASCII locale id. |
LocaleIdBidi
Gets or sets the locale identifier(language) of the formatted right-to-left or complex script characters.
Declaration
public short LocaleIdBidi { get; set; }
Property Value
Type | Description |
---|---|
System.Int16 | The short value that specifies the Bidi locale id. |
Examples
The following example illustrates how to set right-to-left or complex script characters for text.
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe LocaleIdBidi text");
//Set right to left layout for text
text.CharacterFormat.Bidi = true;
//Set language identifier for right to left or complex script characters
text.CharacterFormat.LocaleIdBidi = (short)LocaleIDs.he_IL;
paragraph = section.AddParagraph();
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe LocaleIdBidi text")
'Set right to left layout for text
text.CharacterFormat.Bidi = True
'Set language identifier for right to left or complex script characters
text.CharacterFormat.LocaleIdBidi = CType(LocaleIDs.he_IL, Short)
paragraph = section.AddParagraph()
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
LocaleIdFarEast
Gets or sets the the locale identifier (language) of the formatted Asian characters.
Declaration
public short LocaleIdFarEast { get; set; }
Property Value
Type | Description |
---|---|
System.Int16 | The short value that specifies the far east locale id. |
NumberForm
Gets or sets type of number form(height of the numbers present in the text) for the text.
Declaration
public NumberFormType NumberForm { get; set; }
Property Value
Type | Description |
---|---|
NumberFormType | The NumberFormType member that specifies the type of number form. |
Examples
The following example illustrates how to set number form type for text.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Numbers to describe oldstyle number form 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number style
text.CharacterFormat.NumberForm = NumberFormType.OldStyle;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Numbers to describe lining number form 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number style
text.CharacterFormat.NumberForm = NumberFormType.Lining;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Numbers to describe oldstyle number form 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number style
text.CharacterFormat.NumberForm = NumberFormType.OldStyle
paragraph = section.AddParagraph()
text = paragraph.AppendText("Numbers to describe lining number form 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number style
text.CharacterFormat.NumberForm = NumberFormType.Lining
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
NumberSpacing
Gets or sets the type of number spacing(spacing between numbers in text) for the text.
Declaration
public NumberSpacingType NumberSpacing { get; set; }
Property Value
Type | Description |
---|---|
NumberSpacingType | The NumberSpacingType member that specifies the type of number spacing. |
Examples
The following example illustrates how to set number spacing for text.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Numbers to describe tabular number spacing 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Tabular;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Numbers to describe proportional number spacing 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Proportional;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Numbers to describe tabular number spacing 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Tabular
paragraph = section.AddParagraph()
text = paragraph.AppendText("Numbers to describe proportional number spacing 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Proportional
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
OutLine
Gets or sets a value indicating whether only the outline contour of the characters in the text is rendered, with the inside of each character left empty.
Declaration
public bool OutLine { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to have the outline effect; otherwise, false. |
Position
Gets or sets the vertical position of text measured in points.
Declaration
public float Position { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the vertical position. |
Shadow
Gets or sets a value indicating whether the text is formatted with a shadow.
Declaration
public bool Shadow { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text has shadow; otherwise, false. |
SmallCaps
Gets or sets a value indicating whether the text characters are displayed as their capital letter equivalents, in a font size that is smaller than the actual font size that is specified for this text.
Declaration
public bool SmallCaps { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the text to be displayed as capital letters with smaller font size; otherwise, false. |
Strikeout
Gets or sets a value indicating whether the text is formatted with strikethrough.
Declaration
public bool Strikeout { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to format the text with strike through; otherwise, false. |
StylisticSet
Gets or sets the stylistic set type(defines the look of the text, based on the font used) for the text.
Declaration
public StylisticSetType StylisticSet { get; set; }
Property Value
Type | Description |
---|---|
StylisticSetType | The StylisticSetType member that specifies the type of stylistic set. |
Examples
The following example illustrates how to set number spacing for text.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe stylistic sets");
text.CharacterFormat.FontName = "Gabriola";
//Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet06;
paragraph = section.AddParagraph();
//Add new text
text = paragraph.AppendText("Text to describe stylistic sets");
text.CharacterFormat.FontName = "Gabriola";
//Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet15;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe stylistic sets")
text.CharacterFormat.FontName = "Gabriola"
'Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet06
paragraph = section.AddParagraph()
'Add new text
text = paragraph.AppendText("Text to describe stylistic sets")
text.CharacterFormat.FontName = "Gabriola"
'Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet15
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
SubSuperScript
Gets or sets the subscript or superscript for the text.
Declaration
public SubSuperScript SubSuperScript { get; set; }
Property Value
Type | Description |
---|---|
SubSuperScript | The SubSuperScript member that specifies the type of SubSuperScript. |
TextBackgroundColor
Gets or sets the text background color.
Declaration
public Color TextBackgroundColor { get; set; }
Property Value
Type |
---|
Color |
Remarks
The text background color is not supported by Essential PDF.
TextColor
Gets or sets the System.Drawing.Color for the text.
Declaration
public Color TextColor { get; set; }
Property Value
Type |
---|
Color |
UnderlineStyle
Gets or sets the underline style for the text.
Declaration
public UnderlineStyle UnderlineStyle { get; set; }
Property Value
Type | Description |
---|---|
UnderlineStyle | The |
Remarks
Essential PDF supports only single underline style.
UseContextualAlternates
Gets or sets a value indicating whether to use contextual alternates.
Declaration
public bool UseContextualAlternates { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to use contextual alternates; otherwise, false. |
Examples
The following example illustrates how to set contextual alternates for text.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe contextual alternates");
text.CharacterFormat.FontName = "Segoe Script";
//Set contextual alternates
text.CharacterFormat.UseContextualAlternates = true;
paragraph = section.AddParagraph();
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe contextual alternates")
text.CharacterFormat.FontName = "Segoe Script"
'Set contextual alternates
text.CharacterFormat.UseContextualAlternates = True
paragraph = section.AddParagraph()
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Methods
ClearFormatting()
Clears the character formats applied
Declaration
public override void ClearFormatting()
Overrides
Clone()
Creates a duplicate copy of character format
Declaration
public IOfficeRunFormat Clone()
Returns
Type | Description |
---|---|
IOfficeRunFormat | The reference of the newly created object. |
Remarks
This API is used for internal purpose to clone IOfficeRunFormat.
Dispose()
Releases all resources used by the object.
Declaration
public void Dispose()
Remarks
This API is used for internal purpose to dispose the resources used by IOfficeRunFormat.
GetDefComposite(Int32)
Gets the composite values.
Declaration
protected override FormatBase GetDefComposite(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key | The integer that specifies the key. |
Returns
Type | Description |
---|---|
FormatBase | The FormatBase object. |
Overrides
GetDefValue(Int32)
Returns the default values.
Declaration
protected override object GetDefValue(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key | The integer that specifies the key. |
Returns
Type | Description |
---|---|
System.Object | An object that specifies the default value. |
Overrides
ImportContainer(FormatBase)
Imports the container.
Declaration
protected void ImportContainer(FormatBase format)
Parameters
Type | Name | Description |
---|---|---|
FormatBase | format | The FormatBase object. |
ImportMembers(FormatBase)
Imports the members.
Declaration
protected override void ImportMembers(FormatBase format)
Parameters
Type | Name | Description |
---|---|---|
FormatBase | format | The FormatBase object. |
Overrides
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
OnChange(FormatBase, Int32)
Occurs on format change.
Declaration
protected override void OnChange(FormatBase format, int propKey)
Parameters
Type | Name | Description |
---|---|---|
FormatBase | format | The FormatBase object. |
System.Int32 | propKey | The integer that represents the property key. |
Overrides
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
ReadXmlContent(IXDLSContentReader)
Reads object data from xml attributes.
Declaration
protected override bool ReadXmlContent(IXDLSContentReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentReader | reader | The IXDLSContentReader object. |
Returns
Type | Description |
---|---|
System.Boolean | The value indicating the presence of xml content. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |
Overrides
WriteXmlContent(IXDLSContentWriter)
Writes object data as inside xml element.
Declaration
protected override void WriteXmlContent(IXDLSContentWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentWriter | writer | The IXDLSContentWriter object. |