读书人

C#打印中怎么将e.Graphics所画内容旋转

发布时间: 2013-07-01 12:33:04 作者: rapoo

C#打印中如何将e.Graphics所画内容旋转90度?
//打印事件处理
private void pd_PrintPage(object sender, PrintPageEventArgs e)

在打印事件中e.Graphics.RotateTransform(90.0F);没有起到作用


e.Graphics.RotateTransform(90.0F);

string sTitle = "xxxx";

int width = e.PageBounds.Width;
int height = e.PageBounds.Height;

date = DateTime.Parse(date).ToString("yyyy-MM-dd");
//date=string.Format("yyyy-MM-dd", date);
date = "日期:" + date;
e.Graphics.DrawString(sTitle, titleFont, brush, iLeftMargin + 140, iTopMargin); //标题
e.Graphics.DrawString("", fntTxt, brush, iLeftMargin + 300, iTopMargin += 15);
e.Graphics.DrawString(date, fntTxt, brush, iLeftMargin + 300, iTopMargin += 15); //日期
e.Graphics.DrawString("打印时间:" + DateTime.Now.ToString(), fntTxt, brush, iLeftMargin, iTopMargin);
e.Graphics.DrawString("", fntTxt, brush, iLeftMargin + 300, iTopMargin += 15);
//......

[解决办法]

e.Graphics.TranslateTransform(100, 100);
e.Graphics.RotateTransform(90.0F);
e.Graphics.DrawString("Cylan ", this.Font, Brushes.Black, 0, 0);

更改坐标系统的原点试试
[解决办法]
你那画图代码,根本和坐标原点无关,iLeftMargin + 140, iTopMargin这些值,怎么转也不会改变
[解决办法]
c# GDI+ 完整例子
你先旋转图片,然后打印。
[解决办法]
建议,画完了你要的数据再转动画布
[解决办法]
亲手测试,旋转成功。
//平移的长度,和高度
g.TranslateTransform(30.0F, 0.0F);
//旋转的角度
g.RotateTransform(90.0F);

读书人网 >C#

热点推荐