欢迎分享,转载请注明来源:内存溢出
c# *** 作word源代码_c语言读写word文档表格
在windows应用程序中打印是一项非常重要的功能,在实际运用中也较多,.net中的打印功能都以组件的方式提供,为程序员提供了很大的方便,打印 *** 作通常包括以下四个功能1 打印设置 设置打印机的一些参数比如更改打印机驱动程序等2 页面设置 设置页面大小纸张类型等3 打印预览 类似于word中的打印预览4 打印下面以是一个简单的示例1、打印机设置代码PrintDialogprintDialog = newPrintDialog();printDialog.Document = printDocument;printDialog.ShowDialog();2、打印纸张设置代码PageSetupDialogpageSetupDialog = newPageSetupDialog();pageSetupDialog.Document = printDocument;pageSetupDialog.ShowDialog();3、打印预览代码printDocument.PrintPage += PrintDocument_PrintPage;PrintPreviewDialogprintPreviewDialog = newPrintPreviewDialog{ Document = printDocument }; try{printPreviewDialog.ShowDialog();}catch(Exceptionexcep){MessageBox.Show(excep.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);}4、打印内容设置代码Graphicsg = e.Graphics ;Penp_Line = newPen(Color.Blue, 2f);p_Line.DashStyle = DashStyle.Solid;//g.DrawRectangle(p_Line, newRectangle(100, 50, 300, 200));g.DrawLine(p_Line, newPoint(100, 150), newPoint(400, 150));g.DrawLine(p_Line, newPoint(100, 188), newPoint(400, 188));g.DrawLine(p_Line, newPoint(100, 221), newPoint(400, 221));//g.DrawLine(p_Line, newPoint(200, 83), newPoint(400, 83));g.DrawLine(p_Line, newPoint(200, 116), newPoint(400, 116));//竖线g.DrawLine(p_Line, newPoint(200, 50), newPoint(200, 250));g.DrawLine(p_Line, newPoint(300, 50), newPoint(300, 150));//文字Brushb_Text = newSolidBrush(Color.Black);g.DrawString("姓名", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(230, 55));g.DrawString("性别", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(230, 88));g.DrawString("民族", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(230, 121));g.DrawString("Lena", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(330, 55));g.DrawString("女", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(340, 88));g.DrawString("未知", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(330, 121));g.DrawString("公司名称", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(115, 155));g.DrawString("职位", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(130, 193));g.DrawString("联系电话", newFont("微软雅黑", 12f, FontStyle.Regular), b_Text, newPoint(115, 225));pic = resizeImage(pic,newSize(92,92));g.DrawImage(pic, 102, 52);打印代码printDocument.PrintPage += PrintDocument_PrintPage;try{printDocument.Print();}catch(Exceptionexcep){MessageBox.Show(excep.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);printDocument.PrintController.OnEndPrint(printDocument, newPrintEventArgs());}
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
免费的起名软件推荐_起名软件排行榜
上一篇
2022-04-18
qq批量注册脚本_一键批量注册app推荐
下一篇
2022-04-18
评论列表(0条)