GemBox.Pdf
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfColor Struct

    Namespace:
    GemBox.Pdf.Content
    Assembly:
    GemBox.Pdf.dll

    Represents a color of a PDF content.

    • C#
    • VB.NET
    public struct PdfColor : IEquatable<PdfColor>, IFormattable
    Public Structure PdfColor
        Implements IEquatable(Of PdfColor), IFormattable
    Implements
    System.IEquatable<PdfColor>
    System.IFormattable

    Constructors

    PdfColor(PdfColorSpace, Double)

    Initializes a new instance of the PdfColor structure using the specified color space and a single colorant value.

    • C#
    • VB.NET
    public PdfColor(PdfColorSpace space, double colorant)
    Public Sub New(space As PdfColorSpace, colorant As Double)
    Parameters
    space
    PdfColorSpace

    The color space whose whose Family is not Pattern and ColorantCount is 1.

    colorant
    System.Double

    The single colorant value.

    Exceptions
    System.ArgumentNullException

    space is null.

    System.ArgumentException

    space's Family is Pattern or space's ColorantCount is not 1 or colorant is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    PdfColor(PdfColorSpace, Double, Double, Double)

    Initializes a new instance of the PdfColor structure using the specified color space and three colorant values.

    • C#
    • VB.NET
    public PdfColor(PdfColorSpace space, double colorant1, double colorant2, double colorant3)
    Public Sub New(space As PdfColorSpace, colorant1 As Double, colorant2 As Double, colorant3 As Double)
    Parameters
    space
    PdfColorSpace

    The color space whose whose Family is not Pattern and ColorantCount is 3.

    colorant1
    System.Double

    The first colorant value.

    colorant2
    System.Double

    The second colorant value.

    colorant3
    System.Double

    The third colorant value.

    Exceptions
    System.ArgumentNullException

    space is null.

    System.ArgumentException

    space's Family is Pattern or space's ColorantCount is not 3 or colorant1, colorant2, or colorant3 is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    PdfColor(PdfColorSpace, Double, Double, Double, Double)

    Initializes a new instance of the PdfColor structure using the specified color space and four colorant values.

    • C#
    • VB.NET
    public PdfColor(PdfColorSpace space, double colorant1, double colorant2, double colorant3, double colorant4)
    Public Sub New(space As PdfColorSpace, colorant1 As Double, colorant2 As Double, colorant3 As Double, colorant4 As Double)
    Parameters
    space
    PdfColorSpace

    The color space whose whose Family is not Pattern and ColorantCount is 4.

    colorant1
    System.Double

    The first colorant value.

    colorant2
    System.Double

    The second colorant value.

    colorant3
    System.Double

    The third colorant value.

    colorant4
    System.Double

    The fourth colorant value.

    Exceptions
    System.ArgumentNullException

    space is null.

    System.ArgumentException

    space's Family is Pattern or space's ColorantCount is not 4 or colorant1, colorant2, colorant3, or colorant4 is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    PdfColor(PdfColorSpace, Double[])

    Initializes a new instance of the PdfColor structure using the specified color space and colorant values.

    • C#
    • VB.NET
    public PdfColor(PdfColorSpace space, params double[] colorants)
    Public Sub New(space As PdfColorSpace, ParamArray colorants As Double())
    Parameters
    space
    PdfColorSpace

    The color space whose whose Family is not Pattern and ColorantCount is equal to the number of colorants.

    colorants
    System.Double[]

    The colorant values.

    Exceptions
    System.ArgumentNullException

    space or colorants is null.

    System.ArgumentException

    space's Family is Pattern or space's ColorantCount is not equal to the number of colorants or or any element of the colorants array is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    Properties

    Item[Int32]

    Gets the intensity of the colorant at the specified index.

    • C#
    • VB.NET
    public readonly double this[int colorantIndex] { get; }
    Public ReadOnly Property Item(colorantIndex As Integer) As Double
    Parameters
    colorantIndex
    System.Int32

    The zero-based index of the colorant.

    Property Value
    System.Double

    The intensity of the colorant at the specified index.

    Exceptions
    System.ArgumentOutOfRangeException

    colorantIndex is less than zero or greater than or equal to Space.ColorantCount.

    Pattern

    Gets the pattern or null.

    • C#
    • VB.NET
    public readonly PdfPattern Pattern { get; }
    Public ReadOnly Property Pattern As PdfPattern
    Property Value
    PdfPattern

    The pattern or null.

    Space

    Gets the color space in which the current color is defined.

    • C#
    • VB.NET
    public readonly PdfColorSpace Space { get; }
    Public ReadOnly Property Space As PdfColorSpace
    Property Value
    PdfColorSpace

    The color space in which the current color is defined.

    Methods

    Equals(PdfColor)

    Determines whether the other PdfColor is equal to this PdfColor instance.

    • C#
    • VB.NET
    public bool Equals(PdfColor other)
    Public Function Equals(other As PdfColor) As Boolean
    Parameters
    other
    PdfColor

    The other color to compare with this color instance.

    Returns
    System.Boolean

    true if the other PdfColor is equal to this PdfColor instance; otherwise, false.

    Equals(Object)

    Determines whether the specified System.Object is equal to this PdfColor instance.

    • C#
    • VB.NET
    public override bool Equals(object obj)
    Public Overrides Function Equals(obj As Object) As Boolean
    Parameters
    obj
    System.Object

    The System.Object to compare with this color instance.

    Returns
    System.Boolean

    true if the specified System.Object is a PdfColor and is equal to this PdfColor instance; otherwise, false.

    Overrides
    System.ValueType.Equals(System.Object)

    FromCmyk(Double, Double, Double, Double)

    Creates a new PdfColor structure in DeviceCMYK color space by using the specified cyan, magenta, yellow and black values.

    • C#
    • VB.NET
    public static PdfColor FromCmyk(double cyan, double magenta, double yellow, double black)
    Public Shared Function FromCmyk(cyan As Double, magenta As Double, yellow As Double, black As Double) As PdfColor
    Parameters
    cyan
    System.Double

    The cyan value in range from 0 to 1.

    magenta
    System.Double

    The magenta value in range from 0 to 1.

    yellow
    System.Double

    The yellow value in range from 0 to 1.

    black
    System.Double

    The black value in range from 0 to 1.

    Returns
    PdfColor

    A new PdfColor structure in DeviceCMYK color space created by using the specified cyan, magenta, yellow and black values.

    Exceptions
    System.ArgumentException

    cyan, magenta, yellow, or black is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    FromGray(Double)

    Creates a new PdfColor structure in DeviceGray color space by using the specified gray value.

    • C#
    • VB.NET
    public static PdfColor FromGray(double gray)
    Public Shared Function FromGray(gray As Double) As PdfColor
    Parameters
    gray
    System.Double

    The gray value in range from 0 to 1.

    Returns
    PdfColor

    A new PdfColor structure in DeviceGray color space created by using the specified gray value.

    Exceptions
    System.ArgumentException

    gray is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    FromPattern(PdfColorSpace, PdfPattern, Double[])

    Creates a new PdfColor structure in Pattern color space by using the specified uncolored tilingPdfPattern and colorant values.

    • C#
    • VB.NET
    public static PdfColor FromPattern(PdfColorSpace space, PdfPattern pattern, params double[] colorants)
    Public Shared Function FromPattern(space As PdfColorSpace, pattern As PdfPattern, ParamArray colorants As Double()) As PdfColor
    Parameters
    space
    PdfColorSpace

    The Pattern color space.

    pattern
    PdfPattern

    The pattern.

    colorants
    System.Double[]

    The colorant values.

    Returns
    PdfColor

    A new PdfColor structure in Pattern color space created by using the specified uncolored tiling PdfPattern and colorant values.

    Exceptions
    System.ArgumentNullException

    space or pattern or colorants is null.

    System.ArgumentException

    space's Family is not Pattern or pattern is colored or invalid number of colorants specified or any element of the colorants array is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    FromPattern(PdfPattern)

    Creates a new PdfColor structure in Pattern color space by using the specified colored tilingPdfPattern.

    • C#
    • VB.NET
    public static PdfColor FromPattern(PdfPattern pattern)
    Public Shared Function FromPattern(pattern As PdfPattern) As PdfColor
    Parameters
    pattern
    PdfPattern

    The pattern.

    Returns
    PdfColor

    A new PdfColor structure in Pattern color space created by using the specified colored tiling PdfPattern.

    Exceptions
    System.ArgumentNullException

    pattern is null.

    System.ArgumentException

    pattern is uncolored.

    FromRgb(Double, Double, Double)

    Creates a new PdfColor structure in DeviceRGB color space by using the specified red, green and blue values.

    • C#
    • VB.NET
    public static PdfColor FromRgb(double red, double green, double blue)
    Public Shared Function FromRgb(red As Double, green As Double, blue As Double) As PdfColor
    Parameters
    red
    System.Double

    The red value in range from 0 to 1.

    green
    System.Double

    The green value in range from 0 to 1.

    blue
    System.Double

    The blue value in range from 0 to 1.

    Returns
    PdfColor

    A new PdfColor structure in DeviceRGB color space created by using the specified red, green and blue values.

    Exceptions
    System.ArgumentException

    red, green, or blue is either System.Double.NaN, System.Double.NegativeInfinity or System.Double.PositiveInfinity.

    GetHashCode()

    Returns a hash code for this PdfColor instance.

    • C#
    • VB.NET
    public override int GetHashCode()
    Public Overrides Function GetHashCode As Integer
    Returns
    System.Int32

    An integer value that specifies a hash value for this PdfColor instance.

    Overrides
    System.ValueType.GetHashCode()

    ToString()

    Returns a System.String that represents this PdfColor instance.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    System.String

    A System.String that represents this PdfColor instance.

    Overrides
    System.ValueType.ToString()
    Remarks

    This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).

    ToString(String, IFormatProvider)

    Returns a System.String that represents this PdfColor instance using the specified format and format provider.

    • C#
    • VB.NET
    public string ToString(string format, IFormatProvider formatProvider)
    Public Function ToString(format As String, formatProvider As IFormatProvider) As String
    Parameters
    format
    System.String

    The format to use or null to use the default format.

    formatProvider
    System.IFormatProvider

    The provider to use to format the value or null to obtain the numeric format information from the current locale setting of the operating system.

    Returns
    System.String

    A System.String that represents this PdfColor instance using the specified format and format provider.

    Remarks

    This method should be used primarily for debugging purposes and should be considered volatile (format of its return value might change in future versions).

    TryGetRgb(out Double, out Double, out Double)

    Gets the red, green and blue values of this PdfColor.

    • C#
    • VB.NET
    public bool TryGetRgb(out double red, out double green, out double blue)
    Public Function TryGetRgb(ByRef red As Double, ByRef green As Double, ByRef blue As Double) As Boolean
    Parameters
    red
    System.Double

    The red value in range from 0 to 1 or System.Double.NaN.

    green
    System.Double

    The green value in range from 0 to 1 or System.Double.NaN.

    blue
    System.Double

    The blue value in range from 0 to 1 or System.Double.NaN.

    Returns
    System.Boolean

    true if the color can be represented with red, green and blue values; otherwise, false.

    Operators

    Equality(PdfColor, PdfColor)

    Determines whether first and second PdfColors are equal.

    • C#
    • VB.NET
    public static bool operator ==(PdfColor first, PdfColor second)
    Public Shared Operator =(first As PdfColor, second As PdfColor) As Boolean
    Parameters
    first
    PdfColor

    The first color.

    second
    PdfColor

    The second color.

    Returns
    System.Boolean

    true if first and second colors are equal; otherwise, false.

    Inequality(PdfColor, PdfColor)

    Determines whether first and second PdfColors are not equal.

    • C#
    • VB.NET
    public static bool operator !=(PdfColor first, PdfColor second)
    Public Shared Operator <>(first As PdfColor, second As PdfColor) As Boolean
    Parameters
    first
    PdfColor

    The first color.

    second
    PdfColor

    The second color.

    Returns
    System.Boolean

    true if first and second colors are not equal; otherwise, false.

    Implements

    System.IEquatable<T>
    System.IFormattable

    Examples

    Colors example
    Patterns example
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.