'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Text '' Creates a simple 3-column text layout.'' For a slightly more complex but practically more useful way'' to render text in columns, see BalancedColumns.PublicClassMultiColumnTextFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Dim g = doc.NewPage().GraphicsDim tl = g.CreateTextLayout() tl.DefaultFormat.Font = StandardFonts.Times tl.DefaultFormat.FontSize = 12 tl.TextAlignment = TextAlignment.Justified tl.FirstLineIndent = 72 / 2 tl.ParagraphSpacing = 72 / 8'' Add some text (note that TextLayout interprets vbCr, vbLf and vbCrLf as paragraph delimiter): tl.Append(Util.LoremIpsum(20))'' Set up columns:ConstcolCount = 3'' 1/2" margins all around:Constmargin = 72.0F / 2'' 1/4" gap between columns:ConstcolGap = margin / 4Dim colWidth = (doc.Pages.Last.Size.Width - margin * 2) / colCount - colGap * (colCount - 1) tl.MaxWidth = colWidth tl.MaxHeight = doc.Pages.Last.Size.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 = 0WhileTrue'' 'rest' will accept the text that did not fit:Dim rest AsTextLayout = NothingDim splitResult = tl.Split(Nothing, rest) g.DrawTextLayout(tl, NewPointF(margin + col * (colWidth + colGap), margin))If splitResult <> SplitResult.SplitThenExitWhileEndIf tl = rest col += 1If col = colCountThen doc.Pages.Add() g = doc.Pages.Last.Graphics col = 0EndIfEndWhile'''' Done: doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass