打印生物数据申请表 [英] Print biodata application form
本文介绍了打印生物数据申请表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友
这是nagarjuna plz帮帮我
如何使用C#.net Windows应用程序进行文本框数据打印
hi friend
this is nagarjuna plz help me
how to textbox data print using C#.net windows applications
推荐答案
如何使用C#.net Windows应用程序进行文本框数据打印
how to textbox data print using C#.net windows applications
试试这个
Hi ,
Try this
private void button1_Click(object sender, EventArgs e)
{
//Create image from textbox .
pictureBox1.Image= CreateBitmapImage(textBox1.Text);
// PrintText(); Uncomment if u want in one step
}
private Bitmap CreateBitmapImage(string sImageText)
{
Bitmap objBmpImage = new Bitmap(1, 1);
int intWidth = 0;
int intHeight = 0;
// Create the Font object for the image text drawing.
Font objFont = new Font("Arial", 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
// Create a graphics object to measure the text's width and height.
Graphics objGraphics = Graphics.FromImage(objBmpImage);
// This is where the bitmap size is determined.
intWidth = (int) objGraphics.MeasureString(sImageText, objFont).Width;
intHeight = (int) objGraphics.MeasureString(sImageText, objFont).Height;
// Create the bmpImage again with the correct size for the text and font.
objBmpImage = new Bitmap(objBmpImage, new Size(intWidth, intHeight));
// Add the colors to the new bitmap.
objGraphics = Graphics.FromImage(objBmpImage);
// Set Background color
objGraphics.Clear(Color.White);
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
objGraphics.DrawString(sImageText, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
objGraphics.Flush();
objBmpImage.Save(@"c:/test.jpg");
return (objBmpImage);
}
private void button2_Click(object sender, EventArgs e)
{
PrintText();
}
Void PrintText()
{
Process printjob = new Process();
printjob.StartInfo.FileName = @"c:/test.jpg";
printjob.StartInfo.UseShellExecute = true;
printjob.StartInfo.Verb = "print";
printjob.StartInfo.CreateNoWindow = true;
//printjob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printjob.Start();
}
最好的问候
米特瓦里(M.Mitwalli)
Best Regards
M.Mitwalli
这篇关于打印生物数据申请表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文