By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,812 Members | 875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,812 IT Pros & Developers. It's quick & easy.

How to insert a page break in multi-page document?

P: n/a
Dear all,

For some reason, I have to write my own code to print a document instead of
using report writer. The source is an array with dynamic length. If one
page is full, I have to insert a page break and print a new page to
continue.

The following code segment is what I'm using right now. My question is how
to insert a page break in the middle of the loop since I don't find any
method in PrintDocument similar to this purpose.

Thanks for your attention and kindly help!

James

'>>> code segment
Private objPrintDoc As PrintDocument
Private arrData() As String

Private Shared Sub PrnSlip()
AddHandler objPrintDoc.PrintPage, AddressOf _PrnSlip

Call objPrintDoc.Print()

RemoveHandler objPrintDoc.PrintPage, AddressOf _PrnSlip
End Sub

Private Shared Sub _PrnSlip(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
Dim strData As String

For Each strData In arrData
' loop the array arrData and print
' if page is full, make a page break here and continue
Next
End Sub
'>>>
Jan 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi James,

Based on my research, we need to calculate the printed content size and
handle the PrintPage event to Print out our content.
You can take a look at the sample in the MSDN link below.

PrintDocument.PrintPage Event
http://msdn2.microsoft.com/en-us/lib...ng.printdocume
nt.printpage.aspx

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.