Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print multiple pages

Status
Not open for further replies.

at51178

Technical User
Mar 25, 2002
587
US
Hi VB.net Newbe
I currently have a form with printing functionality (printdoucment1 control and printdialog control) to it.
The form currently takes an image of the form and then prints it out, this has been working great for one page reports but I am currently working on a report who's layout is some what big in height so when I print it, it prints only half of the page how do I set it up so that It asks me how many pages I could print and it will print those pages. or How can I increase the height so that I can print the height of the form. This is the code I am using currently.

--Code --

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

'Now we draw the image to the PrintDocument's Graphics object
'the 0 and 0 are where on the page it will be printed
'0, 0 makes it print in the top left corner of the page
e.Graphics.DrawImage(Me.Print_Image, 0, 0)

End Sub

Private Sub MenuItem2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
'We make the form look pretty before its picture
Application.DoEvents()
Me.Refresh()
Application.DoEvents()

'Get a Graphics Object from the form
Dim FormG As Graphics = Me.CreateGraphics

'Create a bitmap from that graphics
Dim i As New Bitmap(Me.Width, Me.Height, FormG)

'Create a Graphics object in memory from that bitmap
Dim memG As Graphics = Graphics.FromImage(i)

'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = FormG.GetHdc
Dim HDC2 As IntPtr = memG.GetHdc

'get the picture
BitBlt(HDC2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, HDC1, 0, 0, 13369376)
'Clone the bitmap so we can dispose this one
Me.Print_Image = i.Clone()

'Clean Up
FormG.ReleaseHdc(HDC1)
memG.ReleaseHdc(HDC2)
FormG.Dispose()
memG.Dispose()
i.Dispose()

'Show the PrintDialog
PrintDialog1 = New PrintDialog
PrintDialog1.Document = PrintDocument1

Dim r As DialogResult = PrintDialog1.ShowDialog

If r = DialogResult.OK Then
'Print the document
PrintDocument1.Print()
End If
End Sub




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top