I got the a solution from OriginalGriff's Idea of using a Handler to PrintDocument.PrintPage Event and Google.
Step1: Get the image of the whole form.
Step2. Crop the generated image and get image of client area/ form without border.
Step3. Print The Image.
Code For Print Button and PrintDocument.PrintPage Event
Private Sub Print_btn_Click(sender As Object, e As EventArgs) Handles Print_btn.Click
PrintPreviewDialog1.Document = PrintDocument1
PrintDocument1.OriginAtMargins = False
AddHandler PrintDocument1.PrintPage, AddressOf PrintDocument1_PrintPage
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim print_bmp As Bitmap = GetClientareaImage(Me)
e.Graphics.DrawImage(print_bmp, 0, 0)
End Sub
Code For getting image of client area.
**I am using modules to declare functions and Subs that are required globally for this project..
Module Image_processor
Public Function GetControlImage(ByVal ctrl As Control) As Bitmap
Dim ctrl_bmp As New Bitmap(ctrl.Width, ctrl.Height)
ctrl.DrawToBitmap(ctrl_bmp, New Rectangle(0, 0, ctrl.Width, ctrl.Height))
Return ctrl_bmp
End Function
Public Function GetClientareaImage(ByVal frm As Form) As Bitmap
Using Cropped_frm As Bitmap = GetControlImage(frm)
Dim Border As Point = frm.PointToScreen(New Point(0, 0))
Dim client_x As Integer = Border.X - frm.Left
Dim client_y As Integer = Border.Y - frm.Top
Dim client_wd As Integer = frm.ClientSize.Width
Dim client_ht As Integer = frm.ClientSize.Height
Dim client_bmp As New Bitmap(client_wd, client_ht)
Using client_graph As Graphics = Graphics.FromImage(client_bmp)
client_graph.DrawImage(Cropped_frm, 0, 0, New Rectangle(client_x, client_y, client_wd, client_ht), GraphicsUnit.Pixel)
End Using
Return client_bmp
End Using
End Function
End Module
Thaks a lot CodeProject, OriginalGriff and Coders