We can Convert text to image in c# using System.Drawing namespace.
Here we create a bitmap image and use its Graphics property to convert text passed to image and place the image in a picture box.
private void TextToImage()
{
Color BackColor = Color.White;
String FontName = "Times New Roman";
int FontSize = 25;
int Height = 50;
int Width = 300;
//creating bitmap image
Bitmap bitmap = new Bitmap(Width, Height);
//FromImage method creates a new Graphics from the specified Image.
Graphics graphics = Graphics.FromImage(bitmap);
Color color = Color.Gray;
Font font = new Font(FontName, FontSize);
SolidBrush BrushBackColor = new SolidBrush(BackColor);
Pen BorderPen = new Pen(color);
Rectangle displayRectangle = new Rectangle(new Point(0, 0), new Size(Width - 1, Height - 1));
//Drawing a rectangle and filling the background as white
graphics.FillRectangle(BrushBackColor, displayRectangle);
graphics.DrawRectangle(BorderPen, displayRectangle);
//giving the font and color to the string passed
graphics.DrawString(txtEnter.Text,font,Brushes.Red, 0, 0);
pictureBox1.Image = bitmap;
}
Download