//// This code is part of Document Solutions for Imaging demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Text;usingGrapeCity.Documents.Imaging;usingGCTEXT = GrapeCity.Documents.Text; namespaceDsImagingWeb.Demos{// This sample shows how to draw multi-column text on a GcBitmap.publicclassTextColumns {publicGcBitmapGenerateImage(Size pixelSize, float dpi, bool opaque, string[] sampleParams = null) {var bmp = newGcBitmap(pixelSize.Width, pixelSize.Height, true, dpi, dpi);using (var g = bmp.CreateGraphics(Color.White)) { g.Renderer.Multithreaded = true; g.Renderer.SlowAntialiasing = true; var 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(Common.Util.LoremIpsum(20));// Set up columns:constintcolCount = 3;constfloatmargin = 96 / 2; // 1/2" margins all aroundconstfloatcolGap = margin / 2; // 1/4" gap between columnsfloat 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:int col = 0;while (true) {// The TextLayout that will hold the rest of the text which did not fit in the current layout:var tso = newTextSplitOptions(tl) {MinLinesInLastParagraph = 2,MinLinesInFirstParagraph = 2 };var splitResult = tl.Split(tso, outTextLayout rest); g.DrawTextLayout(tl, newPointF(margin + col * (colWidth + colGap), margin));if (splitResult != SplitResult.Split)break; tl = rest;if (++col == colCount)break; } }return bmp; } }}