Click or drag to resize

Color Structure

Represents a color.

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 3.8.6.28 (3.8.6.28)
Syntax
public struct Color : IEquatable<Color>

The Color type exposes the following members.

Constructors
  NameDescription
Public methodColor(Int32)
Initializes a new instance of the Color struct.
Public methodColor(String)
Initializes a new instance of the Color struct.
Public methodColor(Byte, Byte, Byte)
Initializes a new instance of the Color struct.
Public methodColor(Byte, Byte, Byte, Byte)
Initializes a new instance of the Color struct.
Top
Properties
  NameDescription
Public propertyA
Gets the alpha component of this Color instance.
Public propertyB
Gets the blue component of this Color instance.
Public propertyG
Gets the green component of this Color instance.
Public propertyIsAuto
Gets a value indicating whether this Color instance is auto.
Public propertyIsEmpty
Gets a value indicating whether this Color instance is empty.
Public propertyR
Gets the red component of this Color instance.
Top
Methods
  NameDescription
Public methodEquals(Object)
Determines whether the specified Object is equal to this Color instance.
(Overrides ValueTypeEquals(Object).)
Public methodEquals(Color)
Determines whether the otherColor is equal to this Color instance.
Public methodGetHashCode
Gets a hash code for this Color instance.
(Overrides ValueTypeGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns the fully qualified type name of this instance.
(Inherited from ValueType.)
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Determines whether first and second Color are equal.
Public operatorStatic memberInequality
Determines whether first and second Color not equal.
Top
Fields
  NameDescription
Public fieldStatic memberAuto
Represents an auto color.
Public fieldStatic memberBlack
Represents a black color (RGB = 0x000000).
Public fieldStatic memberBlue
Represents a blue color (RGB = 0x0000FF).
Public fieldStatic memberBrown
Represents a brown color (RGB = 0xA52A2A).
Public fieldStatic memberCyan
Represents a cyan color (RGB = 0x00FFFF).
Public fieldStatic memberDarkBlue
Represents a dark blue color (RGB = 0x000080).
Public fieldStatic memberDarkCyan
Represents a dark cyan color (RGB = 0x008080).
Public fieldStatic memberDarkGray
Represents a dark gray color (RGB = 0x808080).
Public fieldStatic memberDarkGreen
Represents a dark green color (RGB = 0x008000).
Public fieldStatic memberDarkMagenta
Represents a dark magenta color (RGB = 0x800080).
Public fieldStatic memberDarkRed
Represents a dark red color (RGB = 0x800000).
Public fieldStatic memberDarkYellow
Represents a dark yellow color(RGB = 0x808000).
Public fieldStatic memberEmpty
Represents an empty color.
Public fieldStatic memberGray
Represents a gray color (RGB = 0x808080).
Public fieldStatic memberGreen
Represents a green color (RGB = 0x00FF00).
Public fieldStatic memberLightGray
Represents a light gray color (RGB = 0xC0C0C0).
Public fieldStatic memberMagenta
Represents a magenta color (RGB = 0xFF00FF).
Public fieldStatic memberOrange
Represents an orange color (RGB = 0xFFA500).
Public fieldStatic memberPink
Represents a pink color (RGB = 0xFFC0CB).
Public fieldStatic memberPurple
Represents a purple color (RGB = 0x800080).
Public fieldStatic memberRed
Represents a red color (RGB = 0xFF0000).
Public fieldStatic memberWhite
Represents a white color (RGB = 0xFFFFFF).
Public fieldStatic memberYellow
Represents a yellow color(RGB = 0xFFFF00).
Top
Examples
How set character formatting in C#
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {

        static void Main(string[] args)
        {
            CharacterFormatting();
        }

        /// <summary>
        /// This sample shows how to set character format. 
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/examples/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 });
        }
    }
}
How set character formatting in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        CharacterFormatting()
    End Sub

    ''' <summary>
    ''' This sample shows how to set character format. 
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/examples/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
See Also