برنامه نویسی

private void button1_Click(object sender, EventArgs e)

        {

         

 

            printDocument1.DefaultPageSettings.Landscape = true;

            Margins margins = new Margins(50, 50, 50, 50);

            printDocument1.DefaultPageSettings.Margins = margins;

            printPreviewDialog1.ClientSize = new Size(800, 600);

            printPreviewDialog1.Document = printDocument1;

            printPreviewDialog1.ShowDialog();

         

           

        }

         private void printDocument1_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e)

        {

           //e.Graphics.FillRectangle(Brushes.Red, new Rectangle(500, 500, 500, 500));

            Image newImage = Image.FromFile("bmp1.bmp");

            int x = 5;

            int y = 10;

            e.Graphics.DrawImage(newImage, x, y);

            Image newImage2 = Image.FromFile("bmp.bmp");

            int x2 = 550;

            int y2 = 10;

            e.Graphics.DrawImage(newImage2, x2, y2);

             /**/

            // Create string to draw.

            String drawString = "شهرستان لارستان";

 

            // Create font and brush.

            Font drawFont = new Font("Arial", 18);

            SolidBrush drawBrush = new SolidBrush(Color.Black);

 

            // Create rectangle for drawing.

            float x3 = 150.0F;

            float y3 = 150.0F;

            float width = 300.0F;

            float height = 50.0F;

            RectangleF drawRect = new RectangleF(x3, y3, width, height);

 

            // Draw rectangle to screen.

            Pen blackPen = new Pen(Color.White);

            e.Graphics.DrawRectangle(blackPen, x3, y3, width, height);

 

            // Draw string to screen.

            e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect);

                 

         }

+ نوشته شده در  پنجشنبه پنجم شهریور ۱۳۸۸ساعت 8:1  توسط ابراری |