Class PdfIndexedColor
Represents an indexed color, based on an indexed colorspace.
Namespace: Syncfusion.Pdf.ColorSpace
Assembly: Syncfusion.Pdf.Portable.dll
Syntax
public class PdfIndexedColor : PdfExtendedColor
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
// Creates indexed color space
PdfIndexedColorSpace colorspace = new PdfIndexedColorSpace();
colorspace.BaseColorSpace = new PdfDeviceColorSpace(PdfColorSpace.RGB);
colorspace.MaxColorIndex = 3;
colorspace.IndexedColorTable = new byte[] { 150, 0, 222, 255, 0, 0, 0, 255, 0, 0, 0, 255 };
// Creates index color
PdfIndexedColor color = new PdfIndexedColor(colorspace);
color.SelectColorIndex = 3;
RectangleF rect = new RectangleF(20, 70, 200, 100);
PdfPen pen = new PdfPen(color);
page.Graphics.DrawRectangle(pen, rect);
doc.Save("IndexedColor.pdf");
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
' Creates indexed color space
Dim colorspace As PdfIndexedColorSpace = New PdfIndexedColorSpace()
colorspace.BaseColorSpace = New PdfDeviceColorSpace(PdfColorSpace.RGB)
colorspace.MaxColorIndex = 3
colorspace.IndexedColorTable = New Byte() { 150, 0, 222, 255, 0, 0, 0, 255, 0, 0, 0, 255 }
' Creates index color
Dim color As PdfIndexedColor = New PdfIndexedColor(colorspace)
color.SelectColorIndex = 3
Dim rect As RectangleF = New RectangleF(20, 70, 200, 100)
Dim pen As PdfPen = New PdfPen(color)
page.Graphics.DrawRectangle(pen, rect)
doc.Save("IndexedColor.pdf")
Constructors
PdfIndexedColor(PdfIndexedColorSpace)
Initializes a new instance of the PdfIndexedColor class.
Declaration
public PdfIndexedColor(PdfIndexedColorSpace colorspace)
Parameters
Type | Name | Description |
---|---|---|
PdfIndexedColorSpace | colorspace | The colorspace. |
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
// Creates indexed color space
PdfIndexedColorSpace colorspace = new PdfIndexedColorSpace();
colorspace.BaseColorSpace = new PdfDeviceColorSpace(PdfColorSpace.RGB);
colorspace.MaxColorIndex = 3;
colorspace.IndexedColorTable = new byte[] { 150, 0, 222, 255, 0, 0, 0, 255, 0, 0, 0, 255 };
// Creates index color
PdfIndexedColor color = new PdfIndexedColor(colorspace);
color.SelectColorIndex = 3;
RectangleF rect = new RectangleF(20, 70, 200, 100);
PdfPen pen = new PdfPen(color);
page.Graphics.DrawRectangle(pen, rect);
doc.Save("IndexedColor.pdf");
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
' Creates indexed color space
Dim colorspace As PdfIndexedColorSpace = New PdfIndexedColorSpace()
colorspace.BaseColorSpace = New PdfDeviceColorSpace(PdfColorSpace.RGB)
colorspace.MaxColorIndex = 3
colorspace.IndexedColorTable = New Byte() { 150, 0, 222, 255, 0, 0, 0, 255, 0, 0, 0, 255 }
' Creates index color
Dim color As PdfIndexedColor = New PdfIndexedColor(colorspace)
color.SelectColorIndex = 3
Dim rect As RectangleF = New RectangleF(20, 70, 200, 100)
Dim pen As PdfPen = New PdfPen(color)
page.Graphics.DrawRectangle(pen, rect)
doc.Save("IndexedColor.pdf")
See Also
Properties
SelectColorIndex
Gets or sets the color index
Declaration
public int SelectColorIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The index of the select color. |
Remarks
The acceptable range for this value is 0 - MaxColorIndex.
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
// Creates indexed color space
PdfIndexedColorSpace colorspace = new PdfIndexedColorSpace();
colorspace.BaseColorSpace = new PdfDeviceColorSpace(PdfColorSpace.RGB);
colorspace.MaxColorIndex = 3;
colorspace.IndexedColorTable = new byte[] { 150, 0, 222, 255, 0, 0, 0, 255, 0, 0, 0, 255 };
// Creates index color
PdfIndexedColor color = new PdfIndexedColor(colorspace);
color.SelectColorIndex = 3;
RectangleF rect = new RectangleF(20, 70, 200, 100);
PdfPen pen = new PdfPen(color);
page.Graphics.DrawRectangle(pen, rect);
doc.Save("IndexedColor.pdf");
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
' Creates indexed color space
Dim colorspace As PdfIndexedColorSpace = New PdfIndexedColorSpace()
colorspace.BaseColorSpace = New PdfDeviceColorSpace(PdfColorSpace.RGB)
colorspace.MaxColorIndex = 3
colorspace.IndexedColorTable = New Byte() { 150, 0, 222, 255, 0, 0, 0, 255, 0, 0, 0, 255 }
' Creates index color
Dim color As PdfIndexedColor = New PdfIndexedColor(colorspace)
color.SelectColorIndex = 3
Dim rect As RectangleF = New RectangleF(20, 70, 200, 100)
Dim pen As PdfPen = New PdfPen(color)
page.Graphics.DrawRectangle(pen, rect)
doc.Save("IndexedColor.pdf")