//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem;usingSystem.IO;usingSystem.Drawing;usingSystem.Collections.Generic;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Text; namespaceDsPdfWeb.Demos.Basics{// This sample demonstrates how to use TextLayout.TabStops to render columns// of floating point numbers aligned in different ways:// - aligned on the decimal point via TabStopAlignment.Separator;// - left-aligned on the tab position using TabStopAlignment.Leading;// - centered around the tab position using TabStopAlignment.Center;// - right-aligned on the tab position using TabStopAlignment.Trailing.publicclassTabsAlignment {publicintCreatePDF(Stream stream) {// Create and set up the document:var doc = newGcPdfDocument();var page = doc.NewPage();var g = page.Graphics;// Create and set up a TextLayout object to print the text:var tl = g.CreateTextLayout(); tl.MaxWidth = page.Size.Width; tl.MaxHeight = page.Size.Height; tl.MarginLeft = tl.MarginRight = tl.MarginTop = tl.MarginBottom = 36; tl.DefaultFormat.Font = StandardFonts.Times; tl.DefaultFormat.FontSize = 10; tl.DefaultFormat.BackColor = Color.FromArgb(217, 217, 217);// Add tab stops with different alignment types// (the first tab's ctor creates a TabStopAlignment.Separator TabStop): tl.TabStops = newList<TabStop>() {newTabStop(72, '.'),newTabStop(72 * 2.5f, TabStopAlignment.Leading),newTabStop(72 * 5, TabStopAlignment.Center),newTabStop(72 * 7.5f, TabStopAlignment.Trailing), };// Render sample text: tl.Append($"TabStopAlignment:\r\n\tSeparator '.'\tLeading\tCenter\tTrailing\r\n");double v0 = 1;double q = (1 + Math.Sqrt(5)) / 2;for (int i = 1; i < 50; ++i) { tl.Append($"\t{v0:R}\t{v0:R}\t{v0:R}\t{v0:R}\r\n"); v0 *= q; } tl.PerformLayout(true);// Draw the text and images: g.DrawTextLayout(tl, PointF.Empty);// Done: doc.Save(stream);return doc.Pages.Count; } }}