場景 Winform中使用zxing和Graphics實現自定義繪製二維碼佈局: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100127885 https://www.cnblogs.com/badaoliumangqizhi ...
場景
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, 20, 20); }
運行效果