110,538
社区成员
发帖
与我相关
我的任务
分享
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//Create font and brush
Font drawFont = new Font("黑体", 20);
Font drawFont1 = new Font("黑体", 16);
SolidBrush drawBrush = new SolidBrush(Color.Black);
Image memoryImage = Image.FromFile(Application.StartupPath + @"\back.jpg"); //背景格式文件路径
e.Graphics.DrawImage(memoryImage, 0, 0, 825, 1178);
Image memoryImage1 = Image.FromFile(Application.StartupPath + @"\top.jpg"); //测试头像文件路径
e.Graphics.DrawImage(memoryImage1, 583, 200, 170, 240);
//基本信息
e.Graphics.DrawString(name, drawFont, drawBrush, 150, 218);//这些数据位置全是一点点试出来的,不科学啊
e.Graphics.DrawString(sex, drawFont, drawBrush, 460, 218);
e.Graphics.DrawString(unit, drawFont, drawBrush, 150, 276);
e.Graphics.DrawString(site, drawFont, drawBrush, 150, 334);
e.Graphics.DrawString(Tel, drawFont, drawBrush, 150, 392);
}
//测试代码
string Look1 = e.Graphics.DpiX.ToString();
string Look2 = e.Graphics.DpiY.ToString();
e.Graphics.DrawString("X分辨率 " + Look1, drawFont1, drawBrush, 105, 640);
e.Graphics.DrawString("Y分辨率 " + Look2, drawFont1, drawBrush, 105, 690);