---
title: "Draw Paragraphs"
canonical: https://www.graphicsmill.com/samples/Text/FormattedText/DrawParagraphs_cs
product: "Graphics Mill"
source: "Text/FormattedText/DrawParagraphs.cs"
---

# Draw Paragraphs

Draws formatted text with several paragraphs.

## Instruction

This code demonstrates how to draw multiple paragraphs with custom text formatting (including first-line indentation and spacing before and after paragraphs) using the GraphicsMill library.
It includes the use of HTML-like inline styling for formatting each paragraph.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetGraphics())
{
    var dummyText = @"<p style='first-line-indent:30pt;space-before:50pt;space-after:20pt;'>" +
        @"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." +
        @"</p>" +

        @"<p style='first-line-indent:50pt;space-before:15pt;space-after:5pt;'>" +
        @"Duis aute irure dolor in reprehenderit " +
        @"in voluptate velit esse cillum dolore eu fugiat nulla pariatur." +
        @"</p>" +

        @"<p style='first-line-indent:20pt;space-before:20pt;'>" +
        @"Excepteur " +
        @"sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " +
        @"mollit anim id est laborum." +
        @"</p>";

    var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
    {
        Rectangle = new System.Drawing.RectangleF(20f, 20f, 560f, 360f),
    };

    graphics.DrawText(boundedText);

    graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);

    bitmap.Save("DrawParagraphs.png");
}
```

## Explanation

The code:

- Creates a 600x400 pixel bitmap with a white background.
- Defines three paragraphs of text with custom styles:
- The first paragraph has a first-line indentation of 30pt, space before 50pt, and space after 20pt.
- The second paragraph has a first-line indentation of 50pt, space before 15pt, and space after 5pt.
- The third paragraph has a first-line indentation of 20pt and space before 20pt.
- The paragraphs are drawn within a bounded rectangle.
- A red rectangle is drawn around the text to highlight the bounded area.
- The final result is saved to "DrawParagraphs.png".

## Tags

- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Formatted Text](<https://www.graphicsmill.com/samples/tags/formatted-text_md>): XML-based formatted text syntax

## Output

- [DrawParagraphs.png](<https://www.graphicsmill.com/samples/Text/compiled/Debug/DrawParagraphs_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.BoundedText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_BoundedText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.BoundedText.Rectangle](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_BoundedText_Rectangle.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.DrawRectangle(Pen,RectangleF)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawRectangle_2_169e24a7.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.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>)
