menu

Document Processing

PdfBrush Class - C# PDF Library API Reference | Syncfusion

    Show / Hide Table of Contents

    PdfBrush Class

    Provides objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.

    Inheritance
    System.Object
    PdfBrush
    PdfGradientBrush
    PdfSolidBrush
    PdfTilingBrush
    Implements
    System.ICloneable
    Namespace: Syncfusion.Pdf.Graphics
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public abstract class PdfBrush : Object, 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 brush.
    PdfBrush 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 brush.
    Dim brush As PdfBrush = 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

    PdfBrush()

    Declaration
    protected PdfBrush()

    Methods

    Clone()

    Creates a new copy of a brush.

    Declaration
    public abstract PdfBrush Clone()
    Returns
    Type Description
    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 brush.
    PdfBrush brush = new PdfSolidBrush(Color.Red);
    //Draw rectangle.
    graphics.DrawRectangle(brush, new RectangleF(0, 0, 200, 100));
    //Clone the existing brush.
    PdfBrush brush1 = brush.Clone();
    (brush1 as PdfSolidBrush).Color = Color.Green;
    //Draw circle.
    graphics.DrawEllipse(brush1, new RectangleF(300, 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 brush.
    Dim brush As PdfBrush = New PdfSolidBrush(Color.Red)
    'Draw rectangle.
    graphics.DrawRectangle(brush, New RectangleF(0, 0, 200, 100))
    'Clone the existing brush.
    Dim brush1 As PdfBrush = brush.Clone()
    TryCast(brush1, PdfSolidBrush).Color = Color.Green
    'Draw circle.
    graphics.DrawEllipse(brush1, New RectangleF(300, 0, 200, 100))
    'Save the document.
    doc.Save("Output.pdf")
    'Close the document.
    doc.Close(True)

    Implements

    System.ICloneable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved