Click here to Skip to main content
15,741,981 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hi friends
I have a form that has a scrollable panel and a picturebox in panel.
https://s6.uupload.ir/files/a_aekt.jpg[^]
now I want print the image in the picturebox completely.

But it doesn't work properly and it prints the part of the image that we see!
I hope I explained my problem well. please guide me.

What I have tried:

my codes are:
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
      Dim bmp = New Bitmap(PictureBox1.DisplayRectangle.Width, PictureBox1.DisplayRectangle.Height)
      PictureBox1.DrawToBitmap(bmp, PictureBox1.ClientRectangle) ' New Rectangle(0, 0, bmp.Width, bmp.Height))
      e.Graphics.DrawImage(bmp, 0, 0)
      e.Graphics.CompositingQuality = CompositingQuality.HighQuality
      e.Graphics.SmoothingMode = SmoothingMode.HighQuality
      e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
  End Sub
Posted
Updated 8-Dec-22 0:07am
v2
Comments
vblover Programmer 8-Dec-22 10:27am    
U can Use New constructor of Bitmap Class to set Ur Image and Size of thet:
Bitmap(Image, Int32, Int32)

See Bitmap Class topic to more information about Bitmap Class

1 solution

Don't use the Picturebox to draw to the printer: use the image property of the PictureBox directly, and draw that to your printer Graphics context.
Remember, the PictureBox may be a significantly different shape or size to teh image it contains!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900