Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfGraphics.FillRectangle(DXBrush, RectangleF) Method

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

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Drawing

#Declaration

public void FillRectangle(
    DXBrush brush,
    RectangleF bounds
)

#Parameters

Name Type Description
brush DXBrush

A DXBrush 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.

#Remarks

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.
PdfDocumentProcessor.RenderNewPage
Draws content on a new page.

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

Fill a Rectangle

using DevExpress.Pdf;
using DevExpress.Drawing;
//...

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

            // Add graphics content to the document page.
            graphics.AddToPageForeground(page, 72, 72);
        }
    processor.SaveDocument("out2.pdf");
}
Process.Start("out.pdf");
See Also