//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Text; namespaceDsPdfWeb.Demos.Basics{// This sample demonstrates the difference between WordWrap and CharWrap// text wrapping modes.publicclassWordCharWrap {publicintCreatePDF(Stream stream) {var str ="Lose nothing in your documents! Document Solutions for PDF includes text and paragraph formatting, " +"special characters, multiple languages, RTL support, vertical and rotated text on all supported platforms."; var doc = newGcPdfDocument();var page = doc.NewPage();var g = page.Graphics; var tl = g.CreateTextLayout(); tl.Append(str); tl.DefaultFormat.Font = StandardFonts.Times; tl.DefaultFormat.FontSize = 12; tl.MaxWidth = 72 * 3; tl.WrapMode = WrapMode.WordWrap; tl.PerformLayout(true); var dy = tl.Lines[0].Height + 72 / 16;var rc = newRectangleF(72, 72 + dy, tl.MaxWidth.Value, 72 * 1.4F); g.DrawString("WrapMode.WordWrap:", tl.DefaultFormat, newPointF(rc.Left, rc.Top - dy)); g.DrawTextLayout(tl, rc.Location); g.DrawRectangle(rc, Color.CornflowerBlue); rc.Offset(0, 72 * 2); tl.WrapMode = WrapMode.CharWrap; tl.PerformLayout(false); g.DrawString("WrapMode.CharWrap:", tl.DefaultFormat, newPointF(rc.Left, rc.Top - dy)); g.DrawTextLayout(tl, rc.Location); g.DrawRectangle(rc, Color.CornflowerBlue); // Done: doc.Save(stream);return doc.Pages.Count; } }}