Printing GDI Drawing objects
-
I am using “System.Drawing.Printing” to print a drawing. Drawing consists a lot of rectangles, and lines. Actually my drawing is very large in size. Can any one tell me how can I devide drawing into pages. I will be thankful to you. Regards,
-
I am using “System.Drawing.Printing” to print a drawing. Drawing consists a lot of rectangles, and lines. Actually my drawing is very large in size. Can any one tell me how can I devide drawing into pages. I will be thankful to you. Regards,
get size of your drawing. create a bitmap using, then get graphics from the bitmap. Now use that graphics object to draw your objects. After finishing drawing objects, copy image to PrintPage event's argument's graphics object.
Bitmap bmp=new Bitmap(width,height); //Now create graphics from this bmp Graphics g=Graphics.FromImage(bmp); //draw you objects to this graphics object //g.DrawRectangle(..) //finish drawing Graphics gr=e.Graphics; //e is PrintPageEventArgs object //int x,y; declare these two variables at class level so that every time you raise PrintPage event they are available with previous values //x=y=0; initialize before calling //Loop to draw all image page by page RectangleF rf=new RectangleF(0,0,printPageWidth, printPageHeight); gr.DrawImage(bmp,rf); //now add width and height of rectangle to start // to get next page x +=printPageWidth e.HasMorePages=true; //this will cause the print event handler to be called again
Sorry i'm not very legible. But hope you will get an idea. Aman Tur