Character |
The CharacterFormat type exposes the following members.
Name | Description | |
---|---|---|
CharacterFormat | Initializes a new instance of the CharacterFormat class. |
Name | Description | |
---|---|---|
AllCaps | Gets or sets a value to display all characters as capital letters. | |
BackgroundColor | Gets or sets the text background color. HighlightColor overrides BackgroundColor. | |
Bold | Gets or sets a value to display all characters as bold. | |
Border | Gets or sets the border for the characters. | |
DoubleStrikethrough | Gets or sets a value to display all characters as double strikethrough. | |
FontASCII | Gets or sets a font name which shall be used to format all characters in the Unicode range (from 0 (zero) through 127). | |
FontColor | Gets or sets the text color. | |
FontComplexScript | Gets or sets a font name which shall be used to format all characters in a complex script Unicode range. | |
FontEastAsian | Gets or sets a font name which shall be used to format all characters in an East Asian Unicode range. | |
FontHighANSI | Gets or sets a font name which shall be used to format all characters in a high ANSI Unicode range. | |
FontName |
When getting, returns FontASCII. When setting, sets FontASCII, FontComplexScript, FontEastAsian and FontHighANSI to the specified value. | |
Hidden | Gets or sets a value to format all characters as hidden. | |
HighlightColor | Gets or sets the text highlight (marker) color. HighlightColor overrides BackgroundColor | |
Italic | Gets or sets a value to display all characters as italic. | |
Kerning | Gets or sets the font size at which kerning starts. | |
Language | Gets or sets the language information. | |
Outline | Gets or sets a value to display an outline. | |
Position | Gets or sets the position of text (in points) relative to the base line. A positive number raises the text, and a negative number lowers it. | |
RightToLeft | When true, the contents of this run shall have right-to-left reading order. Supported only in DOCX format. | |
Scaling | Gets or sets character width scaling in percent. | |
Size | Gets or sets the font size in points. | |
SmallCaps | Gets or sets a value to display all characters as small capital letters. | |
Spacing | Gets or sets the spacing (in points) between characters. | |
Strikethrough | Gets or sets a value to display all characters as strikethrough. | |
Style | Gets or sets the character style. | |
Subscript | Gets or sets a value to display all characters as subscript. | |
Superscript | Gets or sets a value to display all characters as superscript. | |
UnderlineColor | Gets or sets the underline color. | |
UnderlineStyle | Gets or sets the type of underline. |
Name | Description | |
---|---|---|
ClearFormatting |
Clears the formatting.
(Overrides FormatClearFormatting) | |
Clone | Clones this CharacterFormat instance. | |
Equals |
Determines whether the specified object is equal to this
CharacterFormat instance.
(Overrides ObjectEquals(Object)) | |
GetHashCode |
Serves as the default hash function.
(Overrides ObjectGetHashCode) |
See Developer Guide: This sample shows how to set character format
using SautinSoft.Document; namespace Sample { class Sample { static void Main(string[] args) { // Get your free 100-day key here: // https://sautinsoft.com/start-for-free/ CharacterFormatting(); } /// <summary> /// This sample shows how to set character format. /// </summary> /// <remarks> /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/character-format.php /// </remarks> public static void CharacterFormatting() { string documentPath = @"CharacterFormat.pdf"; // Let's create a simple document. DocumentCore dc = new DocumentCore(); // Add a new section. dc.Sections.Add(new Section(dc)); // Add a paragraph. Paragraph p = new Paragraph(dc); p.ParagraphFormat.Alignment = HorizontalAlignment.Left; dc.Sections[0].Blocks.Add(p); // Create a formatted text (Run element) and add it into paragraph. Run run1 = new Run(dc, "It\'s wide formatted text."); run1.CharacterFormat.AllCaps = true; run1.CharacterFormat.BackgroundColor = Color.Pink; run1.CharacterFormat.FontName = "Verdana"; run1.CharacterFormat.Size = 26f; run1.CharacterFormat.FontColor = new Color("#FFFFFF"); p.Inlines.Add(run1); // Create another Run element (container for characters). Run run2 = new Run(dc, "Hi from SautinSoft!"); run2.CharacterFormat.FontColor = Color.DarkGreen; run2.CharacterFormat.UnderlineStyle = UnderlineType.Dashed; run2.CharacterFormat.UnderlineColor = Color.Gray; // Add another formatted text into the paragraph. p.Inlines.Add(run2); // Add new paragraph with formatted text. // We are using ContentRange to insert text. dc.Content.Start.Insert("This is the first paragraph.\n", new CharacterFormat() { FontName = "Calibri", Size = 16.0, FontColor = Color.Orange, Bold = true }); (dc.Sections[0].Blocks[0] as Paragraph).ParagraphFormat.Alignment = HorizontalAlignment.Center; dc.Content.End.Insert("Bold", new CharacterFormat() { Bold = true, FontName = "Times New Roman", Size = 11.0 }); dc.Content.End.Insert(" Italic ", new CharacterFormat() { Italic = true, FontName = "Calibri", Size = 11.0 }); dc.Content.End.Insert("Underline", new CharacterFormat() { UnderlineStyle = UnderlineType.Single, FontName = "Calibri", Size = 11.0 }); dc.Content.End.Insert(" ", new CharacterFormat() { Bold = true, FontName = "Segoe UI", Size = 11.0 }); dc.Content.End.Insert("Strikethrough", new CharacterFormat() { Strikethrough = true, FontName = "Calibri", Size = 11.0 }); // Save our document into PDF format. dc.Save(documentPath, new PdfSaveOptions()); // Open the result for demonstration purposes. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true }); } } }
Imports System Imports System.IO Imports SautinSoft.Document Module Sample Sub Main() CharacterFormatting() End Sub ''' Get your free 100-day key here: ''' https://sautinsoft.com/start-for-free/ ''' <summary> ''' This sample shows how to set character format. ''' </summary> ''' <remarks> ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/character-format.php ''' </remarks> Sub CharacterFormatting() Dim documentPath As String = "CharacterFormat.pdf" ' Let's create a simple document. Dim dc As New DocumentCore() ' Add a new section. dc.Sections.Add(New Section(dc)) ' Add a paragraph. Dim p As New Paragraph(dc) p.ParagraphFormat.Alignment = HorizontalAlignment.Left dc.Sections(0).Blocks.Add(p) ' Create a formatted text (Run element) and add it into paragraph. Dim run1 As New Run(dc, "It's wide formatted text.") run1.CharacterFormat.AllCaps = True run1.CharacterFormat.BackgroundColor = Color.Pink run1.CharacterFormat.FontName = "Verdana" run1.CharacterFormat.Size = 26.0F run1.CharacterFormat.FontColor = New Color("#FFFFFF") p.Inlines.Add(run1) ' Create another Run element (container for characters). Dim run2 As New Run(dc, "Hi from SautinSoft!") run2.CharacterFormat.FontColor = Color.DarkGreen run2.CharacterFormat.UnderlineStyle = UnderlineType.Dashed run2.CharacterFormat.UnderlineColor = Color.Gray ' Add another formatted text into the paragraph. p.Inlines.Add(run2) ' Add new paragraph with formatted text. ' We are using ContentRange to insert text. dc.Content.Start.Insert("This is the first paragraph." & vbLf, New CharacterFormat() With { .FontName = "Calibri", .Size = 16.0, .FontColor = Color.Orange, .Bold = True }) TryCast(dc.Sections(0).Blocks(0), Paragraph).ParagraphFormat.Alignment = HorizontalAlignment.Center dc.Content.End.Insert("Bold", New CharacterFormat() With { .Bold = True, .FontName = "Times New Roman", .Size = 11.0 }) dc.Content.End.Insert(" Italic ", New CharacterFormat() With { .Italic = True, .FontName = "Calibri", .Size = 11.0 }) dc.Content.End.Insert("Underline", New CharacterFormat() With { .UnderlineStyle = UnderlineType.Single, .FontName = "Calibri", .Size = 11.0 }) dc.Content.End.Insert(" ", New CharacterFormat() With { .Bold = True, .FontName = "Segoe UI", .Size = 11.0 }) dc.Content.End.Insert("Strikethrough", New CharacterFormat() With { .Strikethrough = True, .FontName = "Calibri", .Size = 11.0 }) ' Save our document into PDF format. dc.Save(documentPath, New PdfSaveOptions()) ' Open the result for demonstration purposes. System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True}) End Sub End Module