110,537
社区成员
发帖
与我相关
我的任务
分享
//通过GDI+绘制打印文档(160,20)
e.Graphics.DrawString("会员个人信息", new Font("宋体", 10), Brushes.Black, 30, 20);
e.Graphics.DrawLine(new Pen(Color.Black, (float)0.05), 10, 40, 150, 40);
e.Graphics.DrawString("会员卡号:" + lkbl_m_DisplayMCard.Text, new Font("宋体", 10), Brushes.Black, 15, 60);
e.Graphics.DrawString("会员积分:" + lbl_m_DisplayIntegral.Text, new Font("宋体", 10), Brushes.Black, 15, 80);
e.Graphics.DrawString("会员姓名:" + lbl_m_DisplayMName.Text, new Font("宋体", 10), Brushes.Black, 15, 100);
e.Graphics.DrawString("当前余额:" + lbl_m_DisplayMoney.Text, new Font("宋体", 10), Brushes.Black, 15, 120);
e.Graphics.DrawString("会员卡类型:" + lbl_m_DisplayMType.Text, new Font("宋体", 10), Brushes.Black, 15, 140);
e.Graphics.DrawString("消费次数:" + lbl_m_DisplayNumber.Text, new Font("宋体", 10), Brushes.Black, 15, 160);
e.Graphics.DrawString("会员级别:" + lbl_m_DisplayLevel.Text, new Font("宋体", 10), Brushes.Black, 15, 180);
e.Graphics.DrawString("会员状态:" + lbl_m_DisplayState.Text, new Font("宋体", 10), Brushes.Black, 15, 200);
e.Graphics.DrawString("单位职业:" + lbl_m_DisplayCompanl.Text, new Font("宋体", 10), Brushes.Black, 15, 220);
e.Graphics.DrawString("联系电话:" + lbl_m_DisplayMPhone.Text, new Font("宋体", 10), Brushes.Black, 15, 240);
e.Graphics.DrawString("电子邮箱:" + lbl_m_DisplayMEmail.Text, new Font("宋体", 10), Brushes.Black, 15, 260);
e.Graphics.DrawString("地址:" + lbl_m_DisplayMAddress.Text, new Font("宋体", 10), Brushes.Black, 15, 280);
e.Graphics.DrawString("证件号:" + lbl_m_DisplayIDCard.Text, new Font("宋体", 10), Brushes.Black, 15, 300);
e.Graphics.DrawString("加入日期:" + lbl_m_DisplayComeTime.Text, new Font("宋体", 10), Brushes.Black, 15, 320);
if (MessageBox.Show("是否要预览打印文档", "打印预览", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() != DialogResult.OK)
return;
//开启操作系统的防锯齿功能
this.printPreviewDialogCount.UseAntiAlias = true;
//设置要预览的文档
this.printPreviewDialogCount.Document = this.printDocument;
//打开预览窗口
printPreviewDialogCount.ShowDialog();
this.printDocument.DefaultPageSettings.PaperSize = new PaperSize("Custum", 160, 400);
//调用Print方法直接打印文档
this.printDocument.Print();
}
else
{
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() != DialogResult.OK)
return;
this.printDocument.DefaultPageSettings.PaperSize = new PaperSize("Custum", 160, 400);
//调用Print方法直接打印文档
this.printDocument.Print();
}