Class PdfSolidBrush
Represents a brush that fills any object with a solid color.
Implements
System.ICloneable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf.Graphics
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public sealed class PdfSolidBrush : PdfBrush, ICloneable
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.
Declaration
public PdfSolidBrush(PdfExtendedColor color)
Parameters
Type | Name | Description |
---|---|---|
PdfExtendedColor | color | 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.
Declaration
public PdfSolidBrush(PdfColor color)
Parameters
Type | Name | Description |
---|---|---|
PdfColor | color | 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.
Declaration
public PdfColor Color { get; set; }
Property Value
Type |
---|
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.
Declaration
public override PdfBrush Clone()
Returns
Type | Description |
---|---|
PdfBrush | A new instance of the Brush class. |
Overrides
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)
Implements
System.ICloneable