public static void Main()
Console.WriteLine(using System;
using System.Windows.Forms;
using System.Drawing.Printing;
public class StudentInfoPrinter : Form
private TextBox txtName, txtFatherName, txtAddress, txtPincode, txtMobile;
public StudentInfoPrinter()
this.Text = "Student Info Printer";
this.Size = new Size(400, 500);
this.StartPosition = FormStartPosition.CenterScreen;
this.BackgroundImage = Image.FromFile("flower_background.jpg");
this.BackgroundImageLayout = ImageLayout.Stretch;
txtName = new TextBox { PlaceholderText = "Student Name", Location = new Point(20, 20), Width = 300 };
this.Controls.Add(txtName);
txtFatherName = new TextBox { PlaceholderText = "Father's Name", Location = new Point(20, 60), Width = 300 };
this.Controls.Add(txtFatherName);
txtAddress = new TextBox { PlaceholderText = "Address", Location = new Point(20, 100), Width = 300 };
this.Controls.Add(txtAddress);
txtPincode = new TextBox { PlaceholderText = "Pincode", Location = new Point(20, 140), Width = 300 };
this.Controls.Add(txtPincode);
txtMobile = new TextBox { PlaceholderText = "Mobile", Location = new Point(20, 180), Width = 300 };
this.Controls.Add(txtMobile);
btnPrint = new Button { Text = "Print", Location = new Point(20, 220), Width = 100 };
btnPrint.Click += BtnPrint_Click;
this.Controls.Add(btnPrint);
private void BtnPrint_Click(object sender, EventArgs e)
PrintDocument printDoc = new PrintDocument();
printDoc.PrintPage += PrintDoc_PrintPage;
private void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
Font printFont = new Font("Times New Roman", 18);
e.Graphics.DrawString($"Student Name: {txtName.Text}", printFont, Brushes.Black, 100, 100);
e.Graphics.DrawString($"Father's Name: {txtFatherName.Text}", printFont, Brushes.Black, 100, 140);
e.Graphics.DrawString($"Address: {txtAddress.Text}", printFont, Brushes.Black, 100, 180);
e.Graphics.DrawString($"Pincode: {txtPincode.Text}", printFont, Brushes.Black, 100, 220);
e.Graphics.DrawString($"Mobile: {txtMobile.Text}", printFont, Brushes.Black, 100, 260);
public static void Main()
Application.Run(new StudentInfoPrinter());