Winform中使用printDocument控件打印pictureBox中的二维码照片
2024-08-29 06:52:38
场景
Winform中使用zxing和Graphics实现自定义绘制二维码布局:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100127885
https://www.cnblogs.com/badaoliumangqizhi/p/11426919.html
在上面实现将二维码显示在pictureBox之中之后,将其打印。
效果
实现
页面拖拽一个printDocument控件。
拖拽之后的效果
然后再拖拽一个Button按钮,双击进入其点击事件中
private void button7_Click(object sender, EventArgs e)
{
PrintDialog MyPrintDg = new PrintDialog();
MyPrintDg.Document = printDocument1;
if (MyPrintDg.ShowDialog() == DialogResult.OK)
{
try
{
printDocument1.Print();
}
catch
{ //停止打印
printDocument1.PrintController.OnEndPrint(printDocument1, new System.Drawing.Printing.PrintEventArgs());
}
}
}
找到页面设计器中拖拽的printDocument控件上,右击属性,找到事件列表,然后双击其PrintPage事件
编写如下代码:
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(pictureBox1.Image, , );
}
运行效果
最新文章
- android 滚动的缓冲图片
- osgi 2
- CF 370B Berland Bingo
- Xcode中设置按钮在十分钟之内禁用
- windows内核窥探
- 【转】NPAPI 插件无法在 Chrome 42 版及更高版本上正常运行
- tomcat内存溢出之PermGen space
- 用Codility测试你的编码能力
- 【一天一道LeetCode】#17. Letter Combinations of a Phone Number
- Swift 设置某个对象的normal 属性找不到normal 解决方案
- cvLogPolar函数详解
- js如何将选中图片文件转换成Base64字符串?
- 手机布局rem的使用(rem)
- TF-IDF词项权重计算
- easyui 中iframe嵌套页面,提示弹窗遮罩的解决方法,parent.$.messager.alert和parent.$.messager.confirm
- oracle数据库每天自动备份
- linux percpu机制解析【转】
- HDU 多校1.5
- 装饰器(Decorator)模式
- 物理的alpha blend