zoukankan      html  css  js  c++  java
  • 编写WPF程序,完成弹框打印和直接打印

    弹框打印

    PrintDialog pd = new PrintDialog();
    pd.ShowDialog();
    //↓第一个参数是StackPanel控件里面放一个label放打印的文字
    pd.PrintVisual(spdaying, "学生信息");

    直接打印

    using System.Drawing;
    using System.Drawing.Printing;
    
    PrintDocument pd = new PrintDocument();
    //+=的事件 可以按Tab按钮快速创建代码!!!
    pd.PrintPage += pd_PrintPage;
    pd.Print();
    
    void pd_PrintPage(object sender, PrintPageEventArgs e)
    {
        string info = "打印内容
    ";
        //e.图表算法.绘制字符串,Brushes刷子
        e.Graphics.DrawString(info, new Font("正常", 15),System.Drawing.Brushes.Black,0,0);
    }
    //打印条形码
    Bitmap bp = new Bitmap("1.jpg");
    e.Graphics.DrawImage(bp, 0, 0,210,100);
  • 相关阅读:
    开启JAVA学习之旅 Day1
    python二分法及小tips
    简单的注入脚本
    Requests文档 阅读笔记
    多线程
    IO操作
    异常Exception
    Map集合
    Collection集合
    泛型
  • 原文地址:https://www.cnblogs.com/xieyupeng/p/6933300.html
Copyright © 2011-2022 走看看