Represents a color.
Inheritance HierarchySystemObject
SystemValueType
SautinSoft.DocumentColor
Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2025.2.13
Syntaxpublic struct Color : IEquatable<Color>
Public Structure Color
Implements IEquatable(Of Color)
The Color type exposes the following members.
Constructors
Properties | Name | Description |
---|
 | A |
Gets the alpha component of this Color instance.
|
 | B |
Gets the blue component of this Color instance.
|
 | G |
Gets the green component of this Color instance.
|
 | IsAuto |
Gets a value indicating whether this Color instance is auto.
|
 | IsEmpty |
Gets a value indicating whether this Color instance is empty.
|
 | R |
Gets the red component of this Color instance.
|
Top
Methods | Name | Description |
---|
 | Equals(Color) |
Determines whether the otherColor is equal
to this Color instance.
|
 | Equals(Object) |
Determines whether the specified Object is equal to this
Color instance.
(Overrides ValueTypeEquals(Object)) |
 | GetHashCode |
Gets a hash code for this Color instance.
(Overrides ValueTypeGetHashCode) |
Top
Operators
Fields | Name | Description |
---|
  | Auto |
Represents an auto color.
|
  | Black |
Represents a black color (RGB = 0x000000).
|
  | Blue |
Represents a blue color (RGB = 0x0000FF).
|
  | Brown |
Represents a brown color (RGB = 0xA52A2A).
|
  | Cyan |
Represents a cyan color (RGB = 0x00FFFF).
|
  | DarkBlue |
Represents a dark blue color (RGB = 0x000080).
|
  | DarkCyan |
Represents a dark cyan color (RGB = 0x008080).
|
  | DarkGray |
Represents a dark gray color (RGB = 0x808080).
|
  | DarkGreen |
Represents a dark green color (RGB = 0x008000).
|
  | DarkMagenta |
Represents a dark magenta color (RGB = 0x800080).
|
  | DarkRed |
Represents a dark red color (RGB = 0x800000).
|
  | DarkYellow |
Represents a dark yellow color(RGB = 0x808000).
|
  | Empty |
Represents an empty color.
|
  | Gray |
Represents a gray color (RGB = 0x808080).
|
  | Green |
Represents a green color (RGB = 0x00FF00).
|
  | LightGray |
Represents a light gray color (RGB = 0xC0C0C0).
|
  | Magenta |
Represents a magenta color (RGB = 0xFF00FF).
|
  | Orange |
Represents an orange color (RGB = 0xFFA500).
|
  | Pink |
Represents a pink color (RGB = 0xFFC0CB).
|
  | Purple |
Represents a purple color (RGB = 0x800080).
|
  | Red |
Represents a red color (RGB = 0xFF0000).
|
  | White |
Represents a white color (RGB = 0xFFFFFF).
|
  | Yellow |
Represents a yellow color(RGB = 0xFFFF00).
|
Top
ExampleSee Developer Guide: This sample shows how to set character format
How set character formatting in C#
using SautinSoft.Document;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
CharacterFormatting();
}
public static void CharacterFormatting()
{
string documentPath = @"CharacterFormat.pdf";
DocumentCore dc = new DocumentCore();
dc.Sections.Add(new Section(dc));
Paragraph p = new Paragraph(dc);
p.ParagraphFormat.Alignment = HorizontalAlignment.Left;
dc.Sections[0].Blocks.Add(p);
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 = Color.White;
p.Inlines.Add(run1);
Run run2 = new Run(dc, "Hi from SautinSoft!");
run2.CharacterFormat.FontColor = Color.DarkGreen;
run2.CharacterFormat.UnderlineStyle = UnderlineType.Dashed;
run2.CharacterFormat.UnderlineColor = Color.Gray;
p.Inlines.Add(run2);
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 });
dc.Save(documentPath, new PdfSaveOptions());
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true });
}
}
}
How set character formatting in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Module Sample
Sub Main()
CharacterFormatting()
End Sub
Sub CharacterFormatting()
Dim documentPath As String = "CharacterFormat.pdf"
Dim dc As New DocumentCore()
dc.Sections.Add(New Section(dc))
Dim p As New Paragraph(dc)
p.ParagraphFormat.Alignment = HorizontalAlignment.Left
dc.Sections(0).Blocks.Add(p)
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)
Dim run2 As New Run(dc, "Hi from SautinSoft!")
run2.CharacterFormat.FontColor = Color.DarkGreen
run2.CharacterFormat.UnderlineStyle = UnderlineType.Dashed
run2.CharacterFormat.UnderlineColor = Color.Gray
p.Inlines.Add(run2)
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
})
dc.Save(documentPath, New PdfSaveOptions())
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True})
End Sub
End Module
See Also