Hi KatieNgoc,
Refer below link for showing string to image and also refer below sample for drawing image on textbox.
HTML
Name :
<asp:TextBox runat="server" ID="txtName" />
<br />
<asp:Button Text="Print" runat="server" OnClick="Signature" />
Namespaces
C#
using System.Drawing;
using System.Drawing.Imaging;
VB.Net
Imports System.Drawing
Imports System.Drawing.Imaging
Code
C#
protected void Signature(object sender, EventArgs e)
{
Bitmap bitmap = new Bitmap(250, 100, System.Drawing.Imaging.PixelFormat.Format64bppArgb);
Graphics graphics = Graphics.FromImage(bitmap);
graphics.Clear(Color.White);
graphics.DrawString(txtName.Text, new Font("Informal Roman", 25, FontStyle.Regular), new SolidBrush(Color.FromArgb(255, 0, 0)), new PointF(0.4F, 2.4F));
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
bitmap.Dispose();
}
VB.Net
Protected Sub Signature(ByVal sender As Object, ByVal e As EventArgs)
Dim bitmap As Bitmap = New Bitmap(250, 100, System.Drawing.Imaging.PixelFormat.Format64bppArgb)
Dim graphics As Graphics = Graphics.FromImage(bitmap)
graphics.Clear(Color.White)
graphics.DrawString(txtName.Text, New Font("Informal Roman", 25, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 0, 0)), New PointF(0.4F, 2.4F))
bitmap.Save(Response.OutputStream, ImageFormat.Jpeg)
bitmap.Dispose()
End Sub
Screenshot