---
title: "Lay out paragraphs, lists, and tab-aligned columns in a PDF"
canonical: https://www.graphicsmill.com/samples/Codecs/Pdf/AdvancedTypography_cs
product: "Graphics Mill"
source: "Codecs/Pdf/AdvancedTypography.cs"
---

# Lay out paragraphs, lists, and tab-aligned columns in a PDF

This sample shows how to lay out a page of formatted text directly in a PDF using ` BoundedText `'s XML-based markup: regular paragraphs with first-line indentation and paragraph spacing, a bulleted list with custom line leading, and a two-column schedule where each session's title flows from the left and its time is pushed to a right-aligned tab stop by a dot leader, the classic layout of a printed program or table of contents.

## Instruction

Use the PDF API together with formatted text to lay out a page combining several typography features: build one XML-based markup string mixing paragraph, list, and tab elements, wrap it in a BoundedText bounded to the page's margins, and draw it onto a PdfWriter page with Graphics.DrawText.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
const float dpi = 150f;

var pageWidth = UnitConverter.ConvertUnitsToPixels(dpi, 8.5f, Unit.Inch);
var pageHeight = UnitConverter.ConvertUnitsToPixels(dpi, 11f, Unit.Inch);
var margin = UnitConverter.ConvertUnitsToPixels(dpi, 0.5f, Unit.Inch);

var markup =
    "<p style='space-after:14pt;'><span style='font-size:20pt;'>Workshop Schedule</span></p>" +

    "<p style='first-line-indent:18pt;space-after:16pt;'>" +
    "Below is the full-day schedule, followed by a short list of what to bring. " +
    "Session times are tab-aligned to the right margin with a dot leader, the layout classically " +
    "used in printed programs and tables of contents." +
    "</p>" +

    // Each row is a paragraph declaring a single right-aligned tab stop at 540pt (the box's
    // own width) with a dot leader (character code 46). The row's <span> text starts with
    // the session title flowing naturally from the left; a literal tab character then jumps
    // to that stop, where the time is printed, right-aligned against the dots.
    "<p style='space-after:6pt;'><tab style='alignment:right;leader:#46;'>540pt</tab><span>Opening Keynote\t9:00 AM</span></p>" +
    "<p style='space-after:6pt;'><tab style='alignment:right;leader:#46;'>540pt</tab><span>Color Management Deep Dive\t10:30 AM</span></p>" +
    "<p style='space-after:6pt;'><tab style='alignment:right;leader:#46;'>540pt</tab><span>Working with Vector PDFs\t1:00 PM</span></p>" +
    "<p style='space-after:20pt;'><tab style='alignment:right;leader:#46;'>540pt</tab><span>Closing Panel\t3:30 PM</span></p>" +

    "<p style='space-after:6pt;'><span style='font-size:13pt;'>What to bring:</span></p>" +
    "<ul style='type:#9679;'>" +
    "<li><span style='leading:16pt;'>A laptop with the sample project installed</span></li>" +
    "<li><span style='leading:16pt;'>A printed copy of the schedule above</span></li>" +
    "<li><span style='leading:16pt;'>Questions for the closing panel</span></li>" +
    "</ul>";

using (var writer = new PdfWriter("AdvancedTypography.pdf"))
using (var gr = writer.GetGraphics())
{
    writer.AddPage(pageWidth, pageHeight, dpi, dpi);

    var boundedText = new BoundedText(markup, gr.CreateFont("Arial", 11f), new SolidBrush(RgbColor.Black))
    {
        Rectangle = new System.Drawing.RectangleF(margin, margin, pageWidth - (2 * margin), pageHeight - (2 * margin)),
    };

    gr.DrawText(boundedText);
}
```

## Explanation

The code:

- Builds a single formatted-text markup string combining a heading, an indented paragraph, and several other elements.
- Lays out a four-row schedule where each row is a paragraph declaring a single right-aligned ` <tab> ` stop with a dot leader (` leader:#46; `, the period character), followed by a ` <span> ` whose text starts with the session title and uses a literal tab character to jump the time into that stop.
- Adds a bulleted list (` <ul> `) whose items set a custom ` leading ` (line spacing) through inline ` <span> ` styles.
- Wraps the markup in a ` BoundedText `, bounded to the page area inside a half-inch margin.
- Creates a PDF page with ` PdfWriter ` and draws the bounded text onto it with ` Graphics.DrawText `.

## 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
- [PDF](<https://www.graphicsmill.com/samples/tags/pdf_md>): Importing and exporting PDF documents
- [Write](<https://www.graphicsmill.com/samples/tags/write_md>): Writing images with codecs

## Output

- [AdvancedTypography.pdf](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/AdvancedTypography_pdf>) (download)
- [AdvancedTypography.png](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/AdvancedTypography_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.PdfWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_PdfWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.AddPage(Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfWriter_AddPage_4_37f6c741.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfWriter_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.DrawText(Text)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawText_1_f576d03f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Unit](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Unit.htm.md>)
- [Aurigma.GraphicsMill.UnitConverter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_UnitConverter.htm.md>)
- [Aurigma.GraphicsMill.UnitConverter.ConvertUnitsToPixels(Single,Single,Unit)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_UnitConverter_ConvertUnitsToPixels_3_1df1b0a2.htm.md>)
