|
[Visual Basic]
Dim ca As New Canvas
Dim text, pars As String
Dim mywidth, myheight, mylineheight As Integer
text = "In a hole in the ground there lived a hobbit. Not a
nasty, dirty, wet hole, filled with the ends of worms and an oozy
smell, nor yet a dry, bare, sandy hole with..."
pars = "Rect=10,10,290,290"
ca.Color = System.Drawing.Color.Cyan
ca.Width = 300
ca.Height = 300
ca.TextFont = "Franklin Gothic, Verdana, Arial"
ca.TextSize = 18
ca.DrawText(text, pars)
ca.TextArea(text, pars, mywidth, myheight, mylineheight)
ca.DrawShape("rect", "Operation=draw Pos=10,10 Size="
+ mywidth.ToString() + "," + myheight.ToString())
ca.DrawShape("rect", "Operation=draw Pos=10,10 Size="
+ mywidth.ToString() + "," + mylineheight.ToString())
ca.SaveAs(Server.MapPath("textarea.jpg"), "Quality=high")
[C#]
Canvas ca = new Canvas();
int mywidth, myheight, mylineheight;
string text = "In a hole in the ground there lived a hobbit.
Not a nasty, dirty, wet hole, filled with the ends of worms and
an oozy smell, nor yet a dry, bare, sandy hole with...";
string pars = "Rect=10,10,290,290";
ca.Color = System.Drawing.Color.Cyan;
ca.Width = 300;
ca.Height = 300;
ca.TextFont = "Franklin Gothic, Verdana, Arial";
ca.TextSize = 18;
ca.DrawText(text, pars);
ca.TextArea(text, pars, out mywidth, out myheight, out mylineheight);
ca.DrawShape("rect", "Operation=draw Pos=10,10 Size="
+ mywidth.ToString() + "," + myheight.ToString());
ca.DrawShape("rect", "Operation=draw Pos=10,10 Size="
+ mywidth.ToString() + "," + mylineheight.ToString());
ca.SaveAs(Server.MapPath("textarea.jpg"), "Quality=high");
The code above draws out a short piece of text onto a canvas. After
it has drawn it it measures the length of the text and draws a box
round it and around the first line. The image that is saved is shown
below.
textarea.jpg
|
|
|