Team Fly |
Page 189
LISTING 7.7: THE PRINTBMP() SUBROUTINE |
Private Sub PrintBMP() |
In the PrintPage event handler we print the bitmap by calling the DrawImage method of the Graphics object. The code calculates the coordinates of the bitmap's upper-left corner so that it will be centered on the page (regardless of the margins) and then prints the bitmap, with the statements of Listing 7.8.
LISTING 7.8: PRINTING A BITMAP CENTERED ON THE PAGE |
Private Sub PD_PrintPage(ByVal sender As Object, _ |
Notice that this time we retrieve the page's width and height from the PageSettings. Bounds property and we don't have to worry about the orientation of the page. In Listing 7.2 we used the DefaultPageSettings property of the PrintDocument object to extract the coordinates and dimensions of the printable area of the page, and we had to swap the width and height from within our code to account for landscape orientation.
In this chapter we thoroughly discussed the printing capabilities of .NET. We've demonstrated the printing process with practical examples, which you can use in your applications or extend by adding more features.
Team Fly |