Use the following code to convert a paragraph to a JPG image
Color FontColor = Color.Black;
Color BackColor = Color.White;
string FontName = "Verdana";
int FontSize = 36;
string Text = "Hello this is a sample text and will be converted in to JPG Hello this is a sample text and will be converted in to JPG sample text will";
int imgHeight = 1700;
int imgWidth = 1700;
try
{
//Create a Bitmap object with the Width and Height specified earlier
Bitmap objBitmap = new Bitmap(imgWidth, imgHeight);
//Create a Graphics object using this Bitmap object.
Graphics objGraphics = Graphics.FromImage(objBitmap);
//Create Color, Font, and PointF objects.
Font objFont = new Font(FontName, FontSize, FontStyle.Bold);
//Create two SolidBrush type objects.
SolidBrush objBrushForeColor = new SolidBrush(FontColor);
SolidBrush objBrushBackColor = new SolidBrush(BackColor);
//Create a Rectangle to fit the text in
Rectangle imgRectangl = new Rectangle(0, 0, imgWidth, imgHeight);
//Draw rectangle using Graphics object and fill it with BackColor.
objGraphics.FillRectangle(objBrushBackColor, 0, 0, imgWidth, imgHeight);
StringFormat strFormat = (StringFormat) StringFormat.GenericTypographic.Clone();
//Horizontal Allignment
strFormat.Alignment = StringAlignment.Center;
//Vertical Allignment
strFormat.LineAlignment = StringAlignment.Center;
//Draw Text string on the specified rectangle using Graphics object.
objGraphics.DrawString(Text, objFont, objBrushForeColor, imgRectangl, strFormat);
//Save the file on the disk
objBitmap.Save(@"C:\abc.jpg", ImageFormat.Jpeg);
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}