在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
命名空间: using System.Drawing.Printing;
实例化: private PrintDocument pd = new PrintDocument(); 打印事件(Tu是个Image对象):
SolidBrush brush = new SolidBrush(System.Drawing.Color.Black); Font DrawFont = new Font("Arial", 22); /// <summary> /// 打印事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PicturePrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawImage(Tu, 0, 0); //img大小 e.Graphics.DrawString(TicCode, DrawFont, brush, 600, 600); //绘制字符串 e.HasMorePages = false; }
注册事件选择打印机然后打印: pd.PrintPage += PicturePrintDocument_PrintPage; //注册打印事件 pd.PrinterSettings.PrinterName = "HP LaserJet Professional M1213nf MFP"; //打印机选择 pd.Print(); =>就似这么简单
|
请发表评论