Skip to main content
All docs
V26.1
  • PathFragment.Rectangle(RectangleF, Fill, Outline) Method

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public static PathFragment Rectangle(
        RectangleF bounds,
        Fill fill = null,
        Outline outline = null
    )

    Parameters

    Name Type
    bounds RectangleF

    Optional Parameters

    Name Type Default
    fill Fill null
    outline Outline null

    Returns

    Type
    PathFragment

    Example

    How to: Create a Rectangle Path Fragment

    The following code snippet creates a rectangle and adds it to a PDF page:

    PDF page with a red filled rectangle with blue outline created using PathFragment

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing;
    using DevExpress.Drawing.Printing;
    using System.Drawing;
    using System.IO;
    
    using (PdfDocument pdfDocument = new PdfDocument())
    {
        var page = pdfDocument.Pages.Add(DXPaperKind.A4);
        // Create a rectangle path fragment.
        var rectangle = PathFragment.Rectangle(new RectangleF(100, 100, 200, 200));
        rectangle.Fill = Fill.CreateSolid(PdfColor.Red);
        rectangle.Outline = Outline.Create(Fill.CreateSolid(PdfColor.Blue), 5);
        page.AddFragment(rectangle);
    
        pdfDocument.Save(new FileStream("Result.pdf", FileMode.Create, FileAccess.Write));
    }
    
    See Also