现在的位置: 首页 > 综合 > 正文

C#如何实现打印居中

2013年10月25日 ⁄ 综合 ⁄ 共 584字 ⁄ 字号 评论关闭

//实现横向居中

PrintPageEventArgs e;            

StringFormat SF = new StringFormat();
SF.LineAlignment = StringAlignment.Center;                                        //设置属性为水平居中
SF.Alignment = StringAlignment.Center;                                               //设置属性为垂直居中
 RectangleF rect = new RectangleF(0,0,e.PageBounds.Width,e.Graphics.MeasureString("Authors Informations",new Font("Times New Roman",20)).Height);    //其中e.PageBounds属性表示页面全部区域的矩形区域

e.Graphics.MeasureString(string,Font).Height

//表示获取你要打印字符串的高度

 e.Graphics.DrawString("Authors Informations",new Font("Times New Roman",20),Brushes.Black,rect,SF);

【上篇】
【下篇】

抱歉!评论已关闭.