private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){Bitmap myBitmap1 = new Bitmap(pictureBox1.Width, pictureBox1.Height);pictureBox1.DrawToBitmap(myBitmap1, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));e.Graphics.DrawImage(myBitmap1,0,0,0,0);myBitmap1.Dispose();
}
private void print_Click(object sender, EventArgs e){System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();PrintDialog myPrinDialog1 = new PrintDialog();myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);myPrinDialog1.Document = myPrintDocument1;printDocument1.OriginAtMargins = true;
if (myPrinDialog1.ShowDialog() == DialogResult.OK){myPrintDocument1.Print();}
What i modify in code to be able to print the image in center of page