Text Frames

Drawing Text Layout

Render text in multiple columns and along a path using the Frames collection.

Сode Snippet

var text = new Text();
text.String = Texts.LoremIpsum;
text.CharStyle.Size = 40;

var textShape1 = new Path();
textShape1.DrawRectangle(20, 20, 270, 450);

var textShape2 = new Path();
textShape2.DrawRectangle(310, 20, 270, 450);

var shapeTextFrame1 = new ShapeTextFrame()
{
    Shape = textShape1,
};

var shapeTextFrame2 = new ShapeTextFrame()
{
    Shape = textShape2,
};

text.Frames.Add(shapeTextFrame1);
text.Frames.Add(shapeTextFrame2);

var textPath = new Path();
textPath.MoveTo(20, 580);
textPath.CurveTo(250, 500, 480, 580);

var pathText = new PathTextFrame()
{
    Baseline = textPath,
};

text.Frames.Add(pathText);

using (var bitmap = new Bitmap(600, 600, PixelFormat.Format32bppArgb, RgbColor.White))
using (var gr = bitmap.GetAdvancedGraphics())
{
    gr.DrawPath(new Pen(RgbColor.Blue), textShape1);
    gr.DrawPath(new Pen(RgbColor.Blue), textShape2);

    gr.DrawPath(new Pen(RgbColor.Blue), textPath);

    gr.DrawText(text);

    bitmap.Save("TextFrames.png");
}

Output

TextFrames.png

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog