C#winform 打印图像,PrintDialog打印并且设置打印纸张大小

    
    
    //按下打印按钮   
    private void button3_Click(object sender, EventArgs e)   
        {   
           //打印图像   
       //显示打印设置对话框   
        PrintDialog MySettings = new PrintDialog();   
            MySettings.Document = this.printDocument1;   
  
            PaperSize p = null;   
           foreach (PaperSize ps in MySettings.Document.PrinterSettings.PaperSizes)   
            {   
               if (ps.PaperName.Equals("A2"))//这里设置纸张大小,但必须是定义好的   
                    p = ps;   
            }   
            MySettings.Document.DefaultPageSettings.PaperSize = p;   
           if (MySettings.ShowDialog() == DialogResult.OK)   
            {   
               this.printDocument1.Print();   
            }   
        }  

转自:http://hi.baidu.com/yangczcz/item/ec0eca352cb1d34f3075a1d5

你可能感兴趣的:(object,null,button)