Draw Paragraphs
Draws formatted text with several paragraphs.
Сode Snippet
using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetAdvancedGraphics())
{
var dummyText = @"<p style='first-line-indent:30pt;space-before:50pt;space-after:20pt;'>" +
@"Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
@"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut " +
@"enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi " +
@"ut aliquip ex ea commodo consequat." +
@"</p>" +
@"<p style='first-line-indent:50pt;space-before:15pt;space-after:5pt;'>" +
@"Duis aute irure dolor in reprehenderit " +
@"in voluptate velit esse cillum dolore eu fugiat nulla pariatur." +
@"</p>" +
@"<p style='first-line-indent:20pt;space-before:20pt;'>" +
@"Excepteur " +
@"sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt " +
@"mollit anim id est laborum." +
@"</p>";
var boundedText = new BoundedText(dummyText, graphics.CreateFont("Verdana", 18f), new SolidBrush(RgbColor.Black))
{
Rectangle = new System.Drawing.RectangleF(20f, 20f, 560f, 360f),
};
graphics.DrawText(boundedText);
graphics.DrawRectangle(new Pen(RgbColor.Red), boundedText.Rectangle);
bitmap.Save("DrawParagraphs.png");
}
Output
DrawParagraphs.png
For AI-assisted development: Download Graphics Mill Code Samples XML Catalog