預覽列印 printPreviewDialog
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { //列印圖片 e.Graphics.DrawImage(pictureBox1.Image, 160, 20, 250, 100); //列印文字 e.Graphics.DrawString(textBox1.Text, textBox1.Font, new SolidBrush(Color.Black), new Point(50, 50)); }也可以設定列印參數
//設定印A4的一半 直式 printDocument1.DefaultPageSettings.Landscape = true; printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("pag",this.printDocument1.DefaultPageSettings.PaperSize.Width,this.printDocument1.DefaultPageSettings.PaperSize.Height / 2); //列印字體設定 textBox1.Font = new System.Drawing.Font("新細明體", 12F, System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point, ((byte)(136)));執行列印
//預覽列印 printPreviewDialog1.ShowDialog(); //直接列印 printDocument1.Print();
沒有留言:
張貼留言