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

J

James Wong

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
'>>>
 
P

Peter Huang [MSFT]

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top