Class PdfIndexedColor
- Namespace
- Syncfusion.Pdf.ColorSpace
- Assembly
- Syncfusion.Pdf.Portable.dll
Represents an indexed color, based on an indexed colorspace.
public class PdfIndexedColor : PdfExtendedColor
- Inheritance
-
PdfIndexedColor
- Inherited Members
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.
public PdfIndexedColor(PdfIndexedColorSpace colorspace)
Parameters
colorspace
PdfIndexedColorSpaceThe 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
public int SelectColorIndex { get; set; }
Property Value
- int
The index of the select color.
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")
Remarks
The acceptable range for this value is 0 - MaxColorIndex.
- See Also