Draw Paragraphs
View as MarkdownDraws formatted text with several paragraphs.
Code Snippet
using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetGraphics())
{
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
Used APIs
- Aurigma.GraphicsMill.Bitmap.GetGraphics
- Aurigma.GraphicsMill.Drawing.BoundedText
- Aurigma.GraphicsMill.Drawing.BoundedText.Rectangle
- Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)
- Aurigma.GraphicsMill.Drawing.Graphics.DrawRectangle(Pen,RectangleF)
- Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)
- Aurigma.GraphicsMill.Drawing.Pen
- Aurigma.GraphicsMill.Drawing.SolidBrush