Click or drag to resize
Pdf Library for .NET

PdfColor Class

Represents a color used in PDF graphic elements. Construct one from red / green / blue byte components, from a gray level, from CMYK components, or convert implicitly to and from Color.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfColor

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.4
Syntax
public class PdfColor

The PdfColor type exposes the following members.

Constructors
 NameDescription
Public methodPdfColor(Color) Initializes a new instance of the PdfColor class from a Color value.
Public methodPdfColor(Single) Initializes a new instance of the PdfColor class as a gray-scale color.
Public methodPdfColor(Byte, Byte, Byte) Initializes a new instance of the PdfColor class with the specified RGB values.
Public methodPdfColor(Single, Single, Single, Single) Initializes a new instance of the PdfColor class from CMYK components.
Top
Properties
 NameDescription
Public propertyBlue Gets or sets the blue component of the color (0-255).
Public propertyCyan Gets or sets the cyan component of this color (0 to 1).
Public propertyStatic memberEmpty Gets a transparent (empty) color.
Public propertyGray Gets or sets the gray level of this color (0 to 1).
Public propertyGreen Gets or sets the green component of the color (0-255).
Public propertyIsEmpty Gets a value indicating whether this color is empty (transparent).
Public propertyKey Gets or sets the key (black) component of this color (0 to 1).
Public propertyMagenta Gets or sets the magenta component of this color (0 to 1).
Public propertyRed Gets or sets the red component of the color (0-255).
Public propertyYellow Gets or sets the yellow component of this color (0 to 1).
Top
Operators
 NameDescription
Public operatorStatic member(Color to PdfColor) Implicitly converts a Color to a PdfColor.
Public operatorStatic member(PdfColor to Color) Implicitly converts a PdfColor to a Color.
Top
Remarks
The color operators actually written to the document are chosen by the document's color space (see ColorSpace), which defaults to RGB. A color carries all three representations, so the CMYK components set here are used verbatim when the document color space is CMYK, and the gray level when it is gray scale.
Example
PdfColor navy = new PdfColor(0, 32, 96);
byte red = navy.Red;
PdfColor midGray = new PdfColor(0.5f);
PdfColor cmyk = new PdfColor(0.1f, 0.9f, 0.2f, 0.05f);
PdfColor fromDrawing = SelectPdf.Universal.Drawing.Color.Red;
See Also