---
title: "Path Bounded Text"
canonical: https://www.graphicsmill.com/samples/Text/TextLayout/PathBoundedText_cs
product: "Graphics Mill"
source: "Text/TextLayout/PathBoundedText.cs"
---

# Path Bounded Text

Draws text that flows across text frames; a green ellipse serves as a wrapping path that excludes text from its area.

## Instruction

This code demonstrates how to draw text inside multiple bounding paths and wrap it around a custom path using the `PathBoundedText` class.
The text flows between two rectangular bounding paths and is wrapped around an elliptical path. The result is displayed with drawn paths for visualization.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap(600, 300, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetGraphics())
{
    var dummyText = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
        "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " +
        "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo " +
        "consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
        "dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, " +
        "sunt in culpa qui officia deserunt mollit anim id est laborum.";

    var pathBoundedText = new PathBoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black));

    // Adding text areas. When the first text area runs out of space,
    // text will automatically flow to the next one.
    var boundingPath1 = new Path();
    boundingPath1.DrawRectangle(20, 20, 260, 260);
    pathBoundedText.BoundingPaths.Add(boundingPath1);

    var boundingPath2 = new Path();
    boundingPath2.DrawRectangle(320, 20, 260, 260);
    pathBoundedText.BoundingPaths.Add(boundingPath2);

    // Adding paths which you need to wrap with the text
    var wrappingPath = new Path();
    wrappingPath.DrawEllipse(200, 100, 200, 100);
    pathBoundedText.WrappingPaths.Add(wrappingPath);

    graphics.DrawText(pathBoundedText);

    // Drawing frames around text blocks (for demonstration purposes)
    graphics.FillPath(new SolidBrush(RgbColor.LightGreen), wrappingPath);

    var pen = new Pen(RgbColor.Red);
    graphics.DrawPath(pen, boundingPath1);
    graphics.DrawPath(pen, boundingPath2);

    graphics.DrawLine(new Pen(RgbColor.Blue, 2f), 280f, 280f, 320f, 20f);

    bitmap.Save("DrawPathBoundedText.png");
}
```

## Explanation

The code:

- Creates a 600x300 pixel bitmap with a white background.
- Defines a long text block (`dummyText`) to be displayed.
- Creates a `PathBoundedText` object and assigns two rectangular bounding paths for the text to flow across.
- Adds an elliptical path to wrap the text around it.
- Draws the text, bounding paths, and wrapping path on the graphics object.
- Colors the wrapping path in light green, the bounding paths in red, and draws a blue line between the bounding paths.
- Saves the final image as "DrawPathBoundedText.png".

## Tags

- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Text Layout](<https://www.graphicsmill.com/samples/tags/text-layout_md>): Controlling advanced text layout

## Output

- [DrawPathBoundedText.png](<https://www.graphicsmill.com/samples/Text/compiled/Debug/DrawPathBoundedText_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_CreateFont_2_1dbfa9fa.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawLine(Pen,Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawLine_5_b3708ac1.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawPath(Pen,Path)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawPath_2_77634c23.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawText_1_f576d03f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FillPath(Brush,Path)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_FillPath_2_3cee1596.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Path.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path.DrawEllipse(Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Path_DrawEllipse_4_37f6c741.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path.DrawRectangle(Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Path_DrawRectangle_4_37f6c741.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PathBoundedText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_PathBoundedText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PathBoundedText.BoundingPaths](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_PathBoundedText_BoundingPaths.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Pen](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Pen.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Text.WrappingPaths](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_WrappingPaths.htm.md>)
