C# 实现简单打印(一)-打印的内容是单行的
public partial class Form1 : Form { public Form1() { InitializeComponent(); PrintMethod(); } /// <summary> /// 简单打印的三步骤1. 建立PrintDocument对象2. 设置PrintPage打印事件3. 调用Print方法进行打印 /// </summary> public void PrintMethod() { PrintDocument printDoc = new PrintDocument(); printDoc.PrintPage += printDoc_PrintPage; printDoc.Print(); Console.WriteLine("打印成功"); } void printDoc_PrintPage(object sender, PrintPageEventArgs e) { e.Graphics.DrawString("小样你好!", new Font("宋体", 12), Brushes.Black, 50, 50); } }
清清软件园 http://sillysoft.taobao.com