Table of Contents

Struct PdfColor

Namespace
Syncfusion.Pdf.Graphics
Assembly
Syncfusion.Pdf.Portable.dll

Implements structures and routines working with color.

public struct PdfColor
Inherited Members

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = new PdfColor(Color.Red);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As New PdfColor(Color.Red)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Constructors

PdfColor(Color)

Initializes a new instance of the PdfColor class with Syncfusion.Drawing.Color object

public PdfColor(Color color)

Parameters

color Color

Source color object.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = new PdfColor(Color.Red);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As New PdfColor(Color.Red)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

PdfColor(PdfColor)

Initializes a new instance of the PdfColor class with source color

public PdfColor(PdfColor color)

Parameters

color PdfColor

Source color object.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = new PdfColor(new PdfColor(Color.Green));
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As New PdfColor(New PdfColor(Color.Green))
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

PdfColor(byte, byte, byte)

Initializes a new instance of the PdfColor class with Red,Green and Blue values.

public PdfColor(byte red, byte green, byte blue)

Parameters

red byte

Red channel value.

green byte

Green channel value.

blue byte

Blue channel value.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = new PdfColor(200, 120, 80);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As New PdfColor(200, 120, 80)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

PdfColor(float)

Initializes a new instance of the PdfColor class with gray value

public PdfColor(float gray)

Parameters

gray float

Gray value.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = new PdfColor(0.5f);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As New PdfColor(0.5F)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

PdfColor(float, float, float, float)

Initializes a new instance of the PdfColor class with Cyan,Magenta,Yellow and Black channels.

public PdfColor(float cyan, float magenta, float yellow, float black)

Parameters

cyan float

Cyan channel value.

magenta float

Magenta channel value.

yellow float

Yellow channel value.

black float

Black channel value.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = new PdfColor(200, 120, 80, 40);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As New PdfColor(200, 120, 80, 40)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Properties

B

Gets or sets Blue channel value.

public byte B { get; set; }

Property Value

byte

The B.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("SlateBlue");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the blue channel value.   
string text = "The blue channel value is " + pdfColor.B;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("SlateBlue")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the blue channel value.   
Dim text As String = "The blue channel value is " + pdfColor.B
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Blue

Gets the blue color

public float Blue { get; }

Property Value

float

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("Blue");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the blue color value.   
string text = "The blue color value is " + pdfColor.Blue;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("Blue")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the blue color value.   
Dim text As String = "The blue color value is " + pdfColor.Blue
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

C

Gets or sets Cyan channel value.

public float C { get; set; }

Property Value

float

The C.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("SlateBlue");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the cyan channel value. 
string text = "The cyan channel value is " + pdfColor.C;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("SlateBlue")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the cyan channel value.   
Dim text As String = "The cyan channel value is " + pdfColor.C
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Empty

Gets a null color.

public static PdfColor Empty { get; }

Property Value

PdfColor

The empty.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Gets an empty PDF color instance.
PdfColor color = PdfColor.Empty;
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Gets an empty PDF color instance.
Dim color As PdfColor = PdfColor.Empty
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

G

Gets or sets Green channel value.

public byte G { get; set; }

Property Value

byte

The G.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("LawnGreen");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the green channel value.   
string text = "The green channel value is " + pdfColor.G;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("LawnGreen")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the green channel value.   
Dim text As String = "The green channel value is " + pdfColor.G
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Gray

Gets or sets Gray channel value.

public float Gray { get; set; }

Property Value

float

The gray.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("DarkSlateGray");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the gray channel value.   
string text = "The gray channel value is " + pdfColor.Gray;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("DarkSlateGray")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the gray channel value.   
Dim text As String = "The gray channel value is " + pdfColor.Gray
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Green

Gets the green value

public float Green { get; }

Property Value

float

The green.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("Green");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the green color value.   
string text = "The green color value is " + pdfColor.Green;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("Green")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the green color value.   
Dim text As String = "The green color value is " + pdfColor.Green
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

IsEmpty

Gets whether the PDFColor is Empty or not.

public bool IsEmpty { get; }

Property Value

bool

true if this instance is empty; otherwise, false.

Examples

//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(Color.Empty);
//Check the color.
bool isEmpty = pdfColor.IsEmpty;
Console.WriteLine("The Color is " + (isEmpty? "empty" : "not empty"));
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(Color.Empty)
'Check the color.
Dim isEmpty As Boolean = pdfColor.IsEmpty
Console.WriteLine("The Color is " + (If(isEmpty, "empty", "not empty")))

K

Gets or sets Black channel value.

public float K { get; set; }

Property Value

float

The K.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("DarkSlateGray");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the black channel value.   
string text = "The black channel value is " + pdfColor.K;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("DarkSlateGray")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the black channel value.   
Dim text As String = "The black channel value is " + pdfColor.K
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

M

Gets or sets Magenta channel value.

public float M { get; set; }

Property Value

float

The M.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("DarkSlateGray");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the megenta channel value.   
string text = "The megenta channel value is " + pdfColor.M;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("DarkSlateGray")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the megenta channel value.   
Dim text As String = "The megenta channel value is " + pdfColor.M
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

R

Gets or sets Red channel value.

public byte R { get; set; }

Property Value

byte

The R.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("Red");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the red channel value.   
string text = "The red channel value is " + pdfColor.R;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("Red")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the red channel value.   
Dim text As String = "The red channel value is " + pdfColor.R
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Red

Gets the red color

public float Red { get; }

Property Value

float

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("Red");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the red color value.   
string text = "The red color value is " + pdfColor.Red;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("Red")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the red color value.   
Dim text As String = "The red color value is " + pdfColor.Red
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Y

Gets or sets Yellow channel value.

public float Y { get; set; }

Property Value

float

The Y.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create color
Color color = Color.FromName("YellowGreen");
//Create a new PDF color instance.
PdfColor pdfColor = new PdfColor(color);
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(pdfColor);
//Get the yellow channel value.   
string text = "The yellow channel value is " + pdfColor.Y;
//Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create color
Dim color As Color = Color.FromName("YellowGreen")
'Create a new PDF color instance.
Dim pdfColor As New PdfColor(color)
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(pdfColor)
'Get the yellow channel value.   
Dim text As String = "The yellow channel value is " + pdfColor.Y
'Draw string to PDF page.
graphics.DrawString(text, font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

Methods

Equals(PdfColor)

Determines if the specified color is equal to this one.

public bool Equals(PdfColor colour)

Parameters

colour PdfColor

The color.

Returns

bool

True if the color is equal; otherwise - False.

Examples

//Create new PDF color.
PdfColor color1 = new PdfColor(Color.Red);
PdfColor color2 = new PdfColor(253, 0, 0);
//Check both the color are equal.
if(color1.Equals(color2))
Console.WriteLine("Both the colors are same.");
'Create new PDF color.
Dim color1 As New PdfColor(Color.Red)
Dim color2 As New PdfColor(253, 0, 0)
'Check both the color are equal.
If color1.Equals(color2) Then
Console.WriteLine("Both the colors are same.")
End If

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

True if the specified object is equal to the current object; otherwise - False.

Examples

//Create new PDF color.
PdfColor color1 = new PdfColor(Color.Red);
PdfColor color2 = new PdfColor(253, 0, 0);
//Check both the color are equal.
if(color1.Equals(color2))
Console.WriteLine("Both the colors are same.");
'Create new PDF color.
Dim color1 As New PdfColor(Color.Red)
Dim color2 As New PdfColor(253, 0, 0)
'Check both the color are equal.
If color1.Equals(color2) Then
Console.WriteLine("Both the colors are same.")
End If

GetHashCode()

Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToArgb()

Creates the Alpha ,Red ,Green, and Blue value of this PDFColor structure.

public int ToArgb()

Returns

int

ARGB value.

Examples

//Create new PDF color.
PdfColor color1 = new PdfColor(Color.LightBlue);
//Get the ARGB value.
int argb = color1.ToArgb();
Console.WriteLine("ARGB: "+ argb);
'Create new PDF color.
Dim color1 As New PdfColor(Color.LightBlue)
'Get the ARGB value.
Dim argb As Integer = color1.ToArgb()
Console.WriteLine("ARGB: " + argb)

Operators

operator ==(PdfColor, PdfColor)

Operator ==.

public static bool operator ==(PdfColor colour1, PdfColor colour2)

Parameters

colour1 PdfColor

The color 1.

colour2 PdfColor

The color 2.

Returns

bool

True if color 1 is equal to color 2; otherwise False.

Examples

//Create new PDF color.
PdfColor color1 = new PdfColor(Color.Red);
PdfColor color2 = new PdfColor(255, 0, 0);
//Check both the color are equal.
if (color1 == color2)
Console.WriteLine("Both the colors are same.");
'Create new PDF color.
Dim color1 As New PdfColor(Color.Red)
Dim color2 As New PdfColor(255, 0, 0)
'Check both the color are equal.
If color1 = color2 Then
Console.WriteLine("Both the colors are same.")      
End If

implicit operator PdfColor(Color)

Implicit operator.

public static implicit operator PdfColor(Color color)

Parameters

color Color

System.Drawing.Color.

Returns

PdfColor

PDFColor.

Examples

// Create a PDF Document.
PdfDocument doc = new PdfDocument();
//Add pages to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create PDF font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular);
//Create PDF color.
PdfColor color = System.Drawing.Color.Red;
//Create new PDF brush.
PdfBrush brush = new PdfSolidBrush(color);
//Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
' Create a PDF Document.
Dim doc As New PdfDocument()
'Add pages to the document
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create PDF font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Regular)
'Create PDF color.
Dim color As PdfColor = System.Drawing.Color.Red
'Create new PDF brush.
Dim brush As PdfBrush = New PdfSolidBrush(color)
'Draw string to PDF page.
graphics.DrawString("Hello World!", font, brush, PointF.Empty)
'Save the document
doc.Save("Output.pdf")
'Close the document
doc.Close(True)

implicit operator Color(PdfColor)

Implicit operator.

public static implicit operator Color(PdfColor color)

Parameters

color PdfColor

System.Drawing.Color.

Returns

Color

PDFColor.

Examples

  //Create a new PDF color instance.
                     PdfColor pdfColor = new PdfColor(200, 120, 80);
                     //Convert PDF color to System color.
                     System.Drawing.Color systemColor = pdfColor;
                     Console.WriteLine("Red: " + systemColor.R + " Green: " + systemColor.G + " Blue: " + systemColor.B);
        <pre><code class="lang-csharp">'Create a new PDF color instance.
        Dim pdfColor As New PdfColor(200, 120, 80)
        'Convert PDF color to System color.
        Dim systemColor As System.Drawing.Color = pdfColor
        Console.WriteLine("Red: " + systemColor.R + " Green: " + systemColor.G + " Blue: " + systemColor.B)</code></pre>

operator !=(PdfColor, PdfColor)

Operator !=.

public static bool operator !=(PdfColor colour1, PdfColor colour2)

Parameters

colour1 PdfColor

The color 1.

colour2 PdfColor

The color 2.

Returns

bool

True if color 1 is not equal to color 2; otherwise False.

Examples

//Create new PDF color.
PdfColor color1 = new PdfColor(Color.Red);
PdfColor color2 = new PdfColor(250, 0, 0);
//Check both the color are equal.
if (color1 != color2)
Console.WriteLine("The colors are not same.");
'Create new PDF color.
Dim color1 As New PdfColor(Color.Red)
Dim color2 As New PdfColor(250, 0, 0)
'Check both the color are equal.
If color1 = color2 Then
Console.WriteLine("The colors are not same.")      
End If