Table of Contents

Class PdfSolidBrush

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

Represents a brush that fills any object with a solid color.

public sealed class PdfSolidBrush : PdfBrush, ICloneable
Inheritance
PdfSolidBrush
Implements
Inherited Members

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF solid brush.  
PdfSolidBrush brush = new PdfSolidBrush(Color.Red);
//Draw rectangle.
graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfSolidBrush(Color.Red)
'Draw rectangle.
graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Constructors

PdfSolidBrush(PdfExtendedColor)

Initializes a new instance of the PdfSolidBrush class.

public PdfSolidBrush(PdfExtendedColor color)

Parameters

color PdfExtendedColor

The PDF extended color

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
// Create Gray ColorSpace
PdfCalGrayColorSpace calGrayCS = new PdfCalGrayColorSpace();
// Create new instance for PdfCalGrayColor
PdfCalGrayColor gray = new PdfCalGrayColor(calGrayCS);
gray.Gray = 0.2;
//Create new PDF solid brush.  
PdfSolidBrush brush = new PdfSolidBrush(gray);
//Draw rectangle.
graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create GrayColorSpace
Dim calGrayCS As PdfCalGrayColorSpace = New PdfCalGrayColorSpace()
'Create new instance for PdfCalGrayColor
Dim gray As PdfCalGrayColor = New PdfCalGrayColor(calGrayCS)
gray.Gray = 0.2
'Create new PDF gradient brush.           
Dim brush As New PdfSolidBrush(gray)
'Draw rectangle.
graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
See Also

PdfSolidBrush(PdfColor)

Initializes a new instance of the PdfSolidBrush class.

public PdfSolidBrush(PdfColor color)

Parameters

color PdfColor

The color - that represents the color of this brush.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF solid brush.  
PdfSolidBrush brush = new PdfSolidBrush(Color.Red);
//Draw rectangle.
graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfSolidBrush(Color.Red)
'Draw rectangle.
graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Properties

Color

Gets or sets the color of the brush.

public PdfColor Color { get; set; }

Property Value

PdfColor

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF solid brush.  
PdfSolidBrush brush = new PdfSolidBrush(Color.Red);
//Set color.
brush.Color = new PdfColor(Color.Green);
//Draw rectangle.
graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100));           
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfSolidBrush(Color.Red)
'Set color
brush.Color = New PdfColor(Color.Green)
'Draw rectangle.
graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)

Methods

Clone()

Creates a new copy of a brush.

public override PdfBrush Clone()

Returns

PdfBrush

A new instance of the Brush class.

Examples

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Create new PDF solid brush.  
PdfSolidBrush brush = new PdfSolidBrush(Color.Red);
//Draw rectangle.
graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100)); 
//Clone the existing solid brush.
PdfSolidBrush cBrush = brush.Clone() as PdfSolidBrush;
cBrush.Color = Color.Black;
graphics.DrawRectangle(cBrush, new RectangleF(0, 150, 200, 100));
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true);
'Create a new PDF document.
Dim doc As New PdfDocument()
'Add a page to the document.
Dim page As PdfPage = doc.Pages.Add()
'Create PDF graphics for the page
Dim graphics As PdfGraphics = page.Graphics
'Create new PDF gradient brush.           
Dim brush As New PdfSolidBrush(Color.Red)
'Draw rectangle.
graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100))
'Clone the existing solid brush.
Dim cBrush As PdfSolidBrush = TryCast(brush.Clone(), PdfSolidBrush)
cBrush.Color = Color.Black
graphics.DrawRectangle(cBrush, New RectangleF(0, 150, 200, 100))
'Save the document.
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)