Custom user control and printing issues.
I created a user control and a background image. I use the printDocument component and then drawToBitmap to print.
The issue is that there are areas of the bitmap which aren't printing correctly (blank).
When I remove the background image, the print-out looks just the way I expect it to. With the background image in place, printing is whacky as I mentioned above.
Any ideas what the problem may be?
Here's my code:
Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Print only panel 1 and its contents
Dim b As New Bitmap(Panel1.ClientSize.Width, Panel1.ClientSize.Height)
Panel1.DrawToBitmap(b, Panel1.ClientRectangle)
e.Graphics.DrawImage(b, New Point(0, 0))
End Sub
Re: Custom user control and printing issues.
Can you attach some screenshots and/or images to demonstrate the issue? Also, what exactly is on the Panel?
Re: Custom user control and printing issues.
I'm at home for the weekend. Unfortunately, no printer. :-(
The panel consists of all the items I want printed, including:
A table, which contains document title and various document details.
Below that, 5 instances of the user control I created.
The table and user controls both have .png images imported as resources as their background. As you may recall the problem is associated with using background images. Without them, printing seems to work with no issues.
Is there a simple modification I can make to my printDocument1 control to print to FILE (ie. .bmp, .png., etc.) as opposed to print to PRINTER?
I tried to use a code example I found on a forum but it didn't seem to work. Maybe I have to provide a dialog to save the bitmap?...I simply don't know. If so, then I could throw those images up today.
Maybe you're off for the weekend as well.
Either way, as always, I appreciate your willingness to help. It's nice to know there others out there who are willing to share the knowledge. I am a musician and do the same in my profession.
Thanks again.
2 Attachment(s)
Re: Custom user control and printing issues.
Ok, so... Attached are two images. One is a screen shot (only part of the form) of how the print should look. The other is the printed page, scanned.
On the scanned image, a portion of the left and top middle of the image does not print. This seems to only occur when I set background images for the controls and table.