Class PdfCalGrayColor
Represents a calibrated gray color, based on a CalGray colorspace.
Namespace: Syncfusion.Pdf.ColorSpace
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfCalGrayColor : PdfExtendedColor
Examples
// Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document.
PdfPage page = doc.Pages.Add();
RectangleF rect = new RectangleF(20, 70, 100, 50);
// Create Gray ColorSpace
PdfCalGrayColorSpace calGrayCS = new PdfCalGrayColorSpace();
// Create new instance for PdfCalGrayColor
PdfCalGrayColor gray = new PdfCalGrayColor(calGrayCS);
gray.Gray = 0.2;
PdfPen pen = new PdfPen(gray);
PdfBrush brush = new PdfSolidBrush(gray);
// Draws the rectangle
page.Graphics.DrawRectangle(pen, rect);
doc.Save("CalGrayColorSpace.pdf");
' Create a new PDF document.
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
Dim rect As RectangleF = New RectangleF(20, 70, 100, 50)
' Creates GrayColorSpace
Dim calGrayCS As PdfCalGrayColorSpace = New PdfCalGrayColorSpace()
' Create new instance for PdfCalGrayColor
Dim gray As PdfCalGrayColor = New PdfCalGrayColor(calGrayCS)
gray.Gray = 0.2
Dim pen As PdfPen = New PdfPen(gray)
Dim brush As PdfBrush = New PdfSolidBrush(gray)
' Draws the rectangle
page.Graphics.DrawRectangle(pen, rect)
doc.Save("CalGrayColorSpace.pdf")
Constructors
PdfCalGrayColor(PdfColorSpaces)
Initializes a new instance of the PdfCalGrayColor class.
Declaration
public PdfCalGrayColor(PdfColorSpaces colorspace)
Parameters
Type | Name | Description |
---|---|---|
PdfColorSpaces | colorspace | The color space. |
Examples
// Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document.
PdfPage page = doc.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14, PdfFontStyle.Bold);
RectangleF rect = new RectangleF(20, 70, 100, 50);
// Create Gray ColorSpace
PdfCalGrayColorSpace calGrayCS = new PdfCalGrayColorSpace();
// Create new instance for PdfCalGrayColor
PdfCalGrayColor gray = new PdfCalGrayColor(calGrayCS);
gray.Gray = 0.2;
PdfPen pen = new PdfPen(gray);
PdfBrush brush = new PdfSolidBrush(gray);
// Draw the rectangle
page.Graphics.DrawRectangle(pen, rect);
doc.Save("CalGrayColorSpace.pdf");
' Create a new PDF document.
Dim doc As PdfDocument = New PdfDocument()
' Create a page.
Dim page As PdfPage = doc.Pages.Add()
Dim rect As RectangleF = New RectangleF(20, 70, 100, 50)
' Create Gray ColorSpace
Dim calGrayCS As PdfCalGrayColorSpace = New PdfCalGrayColorSpace()
' Create new instance for PdfCalGrayColor
Dim gray As PdfCalGrayColor = New PdfCalGrayColor(calGrayCS)
gray.Gray = 0.2
Dim pen As PdfPen = New PdfPen(gray)
Dim brush As PdfBrush = New PdfSolidBrush(gray)
' Draw the rectangle
page.Graphics.DrawRectangle(pen, rect)
doc.Save("CalGrayColorSpace.pdf")
See Also
Properties
Gray
Gets or sets the gray level for this color.
Declaration
public double Gray { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The gray level of this color. |
Remarks
The acceptable range for this value is [0.0 1.0]. 0.0 means the darkest color that can be achieved, and 1.0 means the lightest color. To know more about color spaces refer this link .
Examples
// Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
// Gets the graphics object.
PdfGraphics g = page.Graphics;
// Created font object
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14, PdfFontStyle.Bold);
RectangleF rect = new RectangleF(20, 70, 100, 50);
// Creates GrayColorSpace
PdfCalGrayColorSpace calGrayCS = new PdfCalGrayColorSpace();
// Create new instance for PdfCalGrayColor
PdfCalGrayColor red = new PdfCalGrayColor(calGrayCS);
red.Gray = 0.2;
PdfPen pen = new PdfPen(red);
PdfBrush brush = new PdfSolidBrush(red);
// Draw the rectangle
g.DrawRectangle(pen, rect);
doc.Save("CalGrayColorSpace.pdf");
' Create a new PDF document.
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
' Gets the graphics object.
Dim g As PdfGraphics = page.Graphics
' Created font object
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 14, PdfFontStyle.Bold)
Dim rect As RectangleF = New RectangleF(20, 70, 100, 50)
' Creates GrayColorSpace
Dim calGrayCS As PdfCalGrayColorSpace = New PdfCalGrayColorSpace()
' Create new instance for PdfCalGrayColor
Dim red As PdfCalGrayColor = New PdfCalGrayColor(calGrayCS)
red.Gray = 0.2
Dim pen As PdfPen = New PdfPen(red)
Dim brush As PdfBrush = New PdfSolidBrush(red)
' Draw the rectangle
g.DrawRectangle(pen, rect)
doc.Save("CalGrayColorSpace.pdf")