Skip to main content

PdfGraphics.FillRectangle(Brush, RectangleF) Method

Fills the interior of a rectangle located in the specified page area.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v23.2.Drawing.dll

NuGet Package: DevExpress.Pdf.Drawing


public void FillRectangle(
    Brush brush,
    RectangleF bounds


Name Type Description
brush Brush

A Brush object that specifies the brush used to fill the rectangle.

bounds RectangleF

A RectangleF structure that specifies a page area (in world coordinate system) where you can draw a rectangle.


This method fills the rectangle interior with a brush. The bounds parameter specifies the page rectangle to fill.

To draw a shape on the PDF page, use one of the following methods:

PdfGraphics.AddToPageForeground, PdfGraphics.AddToPageBackground
These methods allow you to draw content on an existing page.
Draws content on a new page.

The code sample below fills a rectangle with the specified brush.

Fill a Rectangle

using DevExpress.Pdf;
using System.Drawing;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
        using (PdfGraphics graphics = processor.CreateGraphics())
            // Fill a rectangle.
            using (var brush = new SolidBrush(Color.Blue))
                graphics.FillEllipse(brush, new RectangleF(50, 50, 500, 300));

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page, 72, 72);

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FillRectangle(Brush, RectangleF) method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also