'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImports GCTEXT = GrapeCity.Documents.Text '' This sample shows how to draw multi-column text on a GcBitmap.PublicClassTextColumnsFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)Using g = bmp.CreateGraphics(Color.White) g.Renderer.Multithreaded = True g.Renderer.SlowAntialiasing = True Dim tl = g.CreateTextLayout() tl.DefaultFormat.Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "NotoSerif-Regular.ttf")) tl.DefaultFormat.FontSize = 12 tl.TextAlignment = TextAlignment.Justified tl.FirstLineIndent = 96 / 2 tl.ParagraphSpacing = 96 / 8 '' Add some text (note that TextLayout interprets "\r\n", "\r" And "\n" as paragraph delimiters) tl.Append(Util.LoremIpsum(20))'' Set up columnsConstcolCount = 3Constmargin = 96 / 2'' 1/2" margins all aroundConstcolGap = margin / 2'' 1/4" gap between columnsDim colWidth = (bmp.Width - margin * 2 - colGap * (colCount - 1)) / colCount tl.MaxWidth = colWidth tl.MaxHeight = bmp.Height - margin * 2'' Calculate glyphs And perform layout for the whole text: tl.PerformLayout(True) '' In a loop, split And render the text in the current column:Dim col = 0While (True)'' The TextLayout that will hold the rest of the text which did Not fit in the current layout:Dim tso = NewTextSplitOptions(tl) With { .MinLinesInLastParagraph = 2, .MinLinesInFirstParagraph = 2 }Dim rest AsTextLayout = NothingDim splitResult = tl.Split(tso, rest) g.DrawTextLayout(tl, NewPointF(margin + col * (colWidth + colGap), margin))If splitResult <> SplitResult.SplitThenExitWhileEndIf tl = rest col += 1If col = colCountThenExitWhileEndIfEndWhileEndUsingReturn bmpEndFunctionEndClass